Re: Humour

2022-09-06 Thread alister via Python-list
On Sun, 4 Sep 2022 02:08:20 -0700 (PDT), Ali Muhammad wrote:

> Hi python devs it seems you do not have a sense of humour and I am here
> to change that please I request to make it so on April 1st you change
> the print function to a capital P this will be funny and people will use
> language therefore you get more people more money more devs and happier
> people in the world take action to solve depression.

You may want to check the language History (unless you were deliberately 
taking the 'P' & I missed it ) :-)



-- 
Hildebrant's Principle:
If you don't know where you are going, any road will get you 
there.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python & nmap

2022-05-19 Thread alister via Python-list
On Wed, 18 May 2022 23:52:05 +0200, ^Bart wrote:

> Hi guys,
> 
> i need to copy some files from a Debian client to all linux embedded
> clients.
> 
> I know the linux commands like:
> 
> # scp "my_file" root@192.168.205.x/my_directory
> 
> But... I have to upload 100 devices, I have a lan and a dhcp server just
> for this work and I'd like to make a script by Python which can:
> 
> 1) To scan the lan 2) To find which ips are "ready"
> 3) To send files to all of the "ready" clients 4) After I see on the
> display of these clients the successfully update I remove from the lan
> them and I put them to the box to send them to our customers.
> 
> I found https://pypi.org/project/python-nmap/ and I followed the line
> "To check the network status" but... it doesn't work.
> 
> THE INPUT
> 
-
> import nmap nm.scan(hosts='192.168.205.0/24', arguments='-n -sP -PE
> -PA21,23,80,3389')
> hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
> for host, status in hosts_list:
>   print('{0}:{1}'.host)
> 
> THE OUTPUT
> -
> Traceback (most recent call last):
>File "/home/gabriele/Documenti/Python/nmap.py", line 1, in 
>  import nmap
>File "/home/gabriele/Documenti/Python/nmap.py", line 2, in 
>  nm.scan(hosts='192.168.205.0/24', arguments='-n -sP -PE
> -PA21,23,80,3389')
> NameError: name 'nm' is not defined
> 
> Regards.
> ^Bart


Opbservations worth considering
1) could possibly be handled by a simple bash script (My bash skills are 
not great So i would probably still go python myself anyway)
2) Instead of checking availability just try to send & react appropriately 
if it fails (Ask for forgiveness not permission), the client could fail 
after test or during transfer anyway so you will still need this level of 
error checking



-- 
QOTD:
"What women and psychologists call `dropping your armor', we call
"baring your neck."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Style for docstring

2022-04-22 Thread alister via Python-list
On Fri, 22 Apr 2022 14:36:27 -0500, Michael F. Stemper wrote:

> I'm writing a function that is nearly self-documenting by its name,
> but still want to give it a docstring. Which of these would be best from
> a stylistic point of view:
> 
> 
>Tells caller whether or not a permutation is even.
> 
>Determines if a permutation is even. (Alternative is that it's odd.)
> 
>Returns True if permutation is even, False if it is odd.
> 
> 
> (Before somebody suggests it, I'm not going to put six weeks' worth of a
> course in group theory in there to help somebody who doesn't know what
> those standard terms mean.)

four guidance I would sugest Pep257 as a start point
which would suggest "Return True if permutation is even"




-- 
I think my career is ruined!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is there somebody that have experince with python and canopen

2022-04-15 Thread alister via Python-list
On Fri, 15 Apr 2022 10:18:33 -0700 (PDT), luca72.b...@gmail.com wrote:

> We are searching for someone that can develop a python program for use
> servomotor for automotive.

What location & what is the salary?
(although based on the method of recruitment I doubt that you will get 
many takers)



-- 
MS and Y2K: Windows 95, 98, ... and back again to 01

   -- Laurent Szyster
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: eGenix Antispam Bot for Telegram 0.2.0

2022-04-04 Thread alister via Python-list
On Mon, 4 Apr 2022 14:40:57 +0200, eGenix Team wrote:

> 
> 
> ANNOUNCING
> 
> eGenix Antispam Bot for Telegram
> 
> Version 0.2.0
> 
>A simple, yet effective bot implementation
> to address Telegram signup spam.
> 
> This announcement is also available on our web-site for online reading:
> https://www.egenix.com/company/news/eGenix-Antispam-Bot-for-
Telegram-0.2.0-GA.html
> 
> 
> 
> INTRODUCTION
> 
> eGenix has long been running a local user group meeting in Düsseldorf
> called Python Meeting Düsseldorf and we are using a Telegram group for
> most of our communication.
> 
> In the early days, the group worked well and we only had few spammers
> joining it, which we could well handle manually.
> 
> More recently, this has changed dramatically. We are seeing between 2-5
> spam signups per day, often at night. Furthermore, the signups accounts
> are not always easy to spot as spammers, since they often come with
> profile images, descriptions, etc.
> 
> With the bot, we now have a more flexible way of dealing with the
> problem.
> 
> Please see our project page for details and download links:
> 
> https://www.egenix.com/library/telegram-antispam-bot/
> 
> 
> 
> FEATURES
> 
>  * Low impact mode of operation: the bot tries to keep noise in the
>group to a minimum
> 
>  * Several challenge mechanisms to choose from, more can be added as
>needed
> 
>  * Flexible and easy to use configuration
> 
>  * Only needs a few MB of RAM, so can easily be put into a container or
>run on a Raspberry Pi
> 
>  * Can handle quite a bit of load due to the async implementation
> 
>  * Works with Python 3.9+
> 
>  * MIT open source licensed
> 
> 
> 
> NEWS
> 
> The 0.2.0 release is the first public release of the bot.
> 
> It has been battle-tested in production for more than a month already
> and is proving to be a really useful tool to help with Telegram group
> administration.
> 
> ___
> 
> INFORMATION
> 
> About eGenix (http://www.egenix.com/):
> 
> eGenix is a database focused software project, consulting and
> product company delivering expert services and professional quality
> products for companies, Python users and developers.
> 
> About Python (http://www.python.org/):
> 
> Python is an object-oriented Open Source programming language which
> runs on all modern platforms. By integrating ease-of-use, clarity in
> coding, enterprise application connectivity and rapid application
> design, Python establishes an ideal programming platform for today's
> IT challenges.
> 
> Enjoy,
> --
> Marc-Andre Lemburg eGenix.com
> 
> Professional Python Services directly from the Experts (#1, Apr 04 2022)
 Python Projects, Coaching and Support ...https://www.egenix.com/
 Python Product Development ...https://consulting.egenix.com/
> 
> 
> ::: We implement business ideas - efficiently in both time and costs :::
> 
>eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>Registered at Amtsgericht Duesseldorf: HRB 46611
>https://www.egenix.com/company/contact/
>  https://www.malemburg.com/



Classic, spam a news group with an add for anti spam software
can you even spell irony?

-- 
The mosquito exists to keep the mighty humble.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Qualification?

2022-03-30 Thread alister via Python-list
On Tue, 29 Mar 2022 20:49:53 -0400, Dennis Lee Bieber wrote:

> On Tue, 29 Mar 2022 19:26:03 - (UTC), alister
>  declaimed the following:
> 
>>I'm currently considering a career change (not much choice actually just
>>been made redundant).
>>I'd like to be able to turn my interest in python to my advantage, What
>>qualifications do employers look for?
> 
>   Strangely -- knowledge of Python was never a consideration in my
> history... Having a familiarity with multiple languages, software
> engineering principles, and requirements/design analysis were larger
> factors.
> 
>   Python was something I used in support of the primary task, but 
was not
> the end-product itself (for example, an evaluation of various secure
> network filtering hardware, by sending serial numbered packets out one
> NIC,
> through the filter, and in through a second NIC; capturing both out
> via Wireshark; later merging the two captures into a single file of time
> delays, and plotting the timing of the packets intended to pass through
> and verifying that "classified" contents were blocked or sanitized).

Pretty much where I am (only less so) I have used python & flask to make a 
reasonably sucsessfull web app for my fellow engineers at work, lots of 
stuff with home Raspberry pi robotics but no formal qualifications in the 
field.



-- 
Earth is a beta site.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Qualification?

2022-03-29 Thread alister via Python-list
I'm currently considering a career change (not much choice actually just 
been made redundant).
I'd like to be able to turn my interest in python to my advantage, What 
qualifications do employers look for?



-- 
I'm reporting for duty as a modern person.  I want to do the Latin Hustle 
now!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you log in your projects?

2022-02-11 Thread alister via Python-list
On Wed, 9 Feb 2022 19:38:23 +, Martin Di Paola wrote:

>>> - On a line per line basis? on a function/method basis?
> 
> In general I prefer logging line by line instead per function.
> 
> It is easy to add a bunch of decorators to the functions and get the
> logs of all the program but I most of the time I end up with very
> confusing logs.
> 
> There are exceptions, yes, but I prefer the line by line where the log
> should explain what is doing the code.
> 
>>> - Which kind of variable contents do you write into your logfiles?
>>> - How do you decide, which kind of log message goes into which level?
>>> - How do you prevent logging cluttering your actual code?
> 
> These three comes to the same answer: I think on whom is going to read
> the logs.
> 
> If the logs are meant to be read by my users I log high level messages,
> specially before parts that can take a while (like the classic
> "Loading...").
> 
> If I log variables, those must be the ones set by the users so he/she
> can understand how he/she is controlling the behaviour of the program.
> 
> For exceptions I print the message but not the traceback. Across the
> code tag some important functions to put an extra message that will
> enhance the final message printed to the user.
> 
> https://github.com/byexamples/byexample/blob/master/byexample/
common.py#L192-L238
> 
> For example:
> 
>  for example in examples:
>  with enhance_exceptions(example, ...):
>  foo()
> 
> So if an exception is raised by foo(), enhance_exceptions() will attach
> to it useful information for the user from the example variable.
> 
> In the main, then I do the pretty print
> https://github.com/byexamples/byexample/blob/master/byexample/
byexample.py#L17-L22
> 
> If the user of the logs is me or any other developer I write more
> debugging stuff.
> 
> My approach is to not log anything and when I have to debug something I
> use a debugger + some prints. When the issue is fixed I review which
> prints would be super useful and I turn them into logs and the rest is
> deleted.
> 
> 
> On Tue, Feb 08, 2022 at 09:40:07PM +0100, Marco Sulla wrote:
>>These are a lot of questions. I hope we're not off topic.
>>I don't know if mine are best practices. I can tell what I try to do.
>>
>>On Tue, 8 Feb 2022 at 15:15, Lars Liedtke  wrote:
>>> - On a line per line basis? on a function/method basis?
>>
>>I usually log the start and end of functions. I could also log inside a
>>branch or in other parts of the function/method.
>>
>>> - Do you use decorators to mark beginnings and ends of
>>> methods/functions in log files?
>>
>>No, since I put the function parameters in the first log. But I think
>>that such a decorator it's not bad.
>>
>>> - Which kind of variable contents do you write into your logfiles? Of
>>> course you shouldn't leak secrets...
>>
>>Well, all the data that is useful to understand what the code is doing.
>>It's better to repeat the essential data to identify a specific call in
>>all the logs of the function, so if it is called simultaneously by more
>>clients you can distinguish them
>>
>>> - How do you decide, which kind of log message goes into which level?
>>
>>It depends on the importance, the verbosity and the occurrences of the
>>logs.
>>
>>> - How do you prevent logging cluttering your actual code?
>>
>>I have the opposite problem, I should log more. So I can't answer your
>>question.
>>--
>>https://mail.python.org/mailman/listinfo/python-list
In my current project I use the loggin module & write to a file
I log at info level for the entry & exit of each function/method
& scatter debug level logs for arease where I need to check data is as 
expected
I have also found Ansi colour codes usefull when skiming through the 
output





-- 
If an experiment works, something has gone wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a string with comma in one column of CSV file

2022-01-15 Thread alister via Python-list
On Sat, 15 Jan 2022 20:56:22 + (UTC), Mahmood Naderan wrote:

> Hi,
> I use the following line to write some information to a CSV file which
> is comma delimited.
> 
> f = open(output_file, 'w', newline='')
> wr = csv.writer(f)
> ...
> f.write(str(n) + "," + str(key) + "\n" )
> 
> 
> Problem is that key is a string which may contain ',' and this causes
> the final CSV file to have more than 2 columns, while I want to write
> the whole key as a single column.
> 
> I know that wr.writerow([key]) writes the entire key in one column, but
> I would like to do the same with write(). Any idea to fix that?
> 
> 
> Regards,
> Mahmood

you need to quote the data
the easies way to ensure this is to inculde to QUOTE_ALL option when 
opening the file

wr = csv.writer(output, quoting=csv.QUOTE_ALL)



-- 
Chocolate chip.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-09 Thread alister via Python-list
On Sun, 9 Jan 2022 08:53:58 -0800 (PST), NArshad wrote:

> -Whose time??
> My time I do not have not time to switch to a database but if necessary
> I can use the database to make changes in Excel column entries.
> 
> -No changes??
> 
> I cannot change the column names.
> 
> 
> -“maybe the point is that at any time one has to be able to re-export to
> the original excel format?  (And why??  Do we actually need "reporting":
> then we can generate a PDF rather, otherwise we can just send out a
> CSV... etc.)  Is that it?”
> 
> PDF is not required and I am not doing any reporting at all.
> 
> 
> -“loading the data from the CSV file in memory into a pandas dataframe,
> working with that, and eventually saving back to the CSV file might be
> just enough... as long as there is never more than one user concurrently
> using the system, or you need also implement some concurrency management
> (you need that with a database, too, anyway): but that's tutorial number
> 2, and already quite less trivial, since to begin with it requires a
> more thorough analysis”
> 
> No need to save the CSV file once the work is done CSV file will be
> exited without saving. If the above is going to work then I will be
> requiring something to see how to do all this that’s why written
> tutorial. For a more thorough analysis I have written once again what I
> want to do.
> 
> Only the four functions that I have written below I have to make and
> that’s it. All the input will be entered by the user on a website:
> 1. First, I have to check in the Excel sheet or table whether the book
> user has entered is present in the book bank or not.
>  
> 2. If a book is present and the quantity of the required book is greater
> than 0 (COPIES_LEFT column in excel file) and if the user wants the
> book, it will be assigned to the user which he will take from the book
> bank physically. When COPIES_LEFT is less than or equal to 0 the message
> will be “Book finished or not present”.
>  
> 3. The quantity of the book in the Excel file will be reduced by 1 in
> the COPIES_LEFT column and the name of the borrower or user will be
> entered/added in the Excel file table or sheet already made and the
> column name is BORROWER’S NAME.
>  
> 4. The borrower’s or user name can be more than one so they will be
> separated with a comma in the Excel file BORROWER’S NAME column.
> 
> 
> -1st save the data from excel as a CSV file
> 
> you will find the CSV module makes these much easier to deal with, even
> if you do not import into a DB (although even then I would import into
> SQL-
> lite just for the benefits of the search algorithms)
> 
> If in order to do the required task it is necessary to use SQLite and
> without using SQLite I cannot do what I want to do then I think I have
> to go for SQLite otherwise CSV looks to me as fine. To do everything
> using CSV I will be requiring a tutorial to see how to do all this.
> 
> Anything not clear?

Sql-lite is not essential to the task CSV would be sufficient, but you may 
find that taking the time to learn it pays off later (even if you wait 
untill after this project)




-- 
Trying to establish voice contact ... please yell into 
keyboard.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-09 Thread alister via Python-list
On Sat, 8 Jan 2022 23:04:20 -0800 (PST), NArshad wrote:

> On Friday, 7 January 2022 at 02:59:17 UTC+5, alister wrote:
>> On Thu, 6 Jan 2022 10:55:30 -0800 (PST), NArshad wrote:
>> 
>> > All this is going to be in python’s flask and HTML only
>> > 
>> > 1. First, I have to check in the Excel sheet or table whether the
>> > book user has entered is present in the book bank or not.
>> >
>> Excel is the wrong application for storing this data - it should be in
>> a database
>> > 2. If a book is present and the quantity of the required book is
>> > greater than 0 (COPIES_LEFT column in excel file) and if the user
>> > wants the book, it will be assigned to the user which he will take
>> > from the book bank physically. When COPIES_LEFT will is less than or
>> > equal to 0 the message will be “Book finished or not present”.
>> Again Excel is not the correct application for processing this data
>> > 
>> > 3. The quantity of the book in the Excel file will be reduced by 1 in
>> > the COPIES_LEFT column and the name of the borrower or user will be
>> > entered/added in the Excel file table or sheet already made and the
>> > column name is BORROWER’S NAME.
>> >
>> Database!
>> > 4. The borrower’s or user name can be more than one so they will be
>> > separated with a comma in the Excel file BORROWER’S NAME column.
>> >
>> Database
>> > 
>> > - All functions mentioned above are to be deployed on the website
>> > pythonhow.com so make according to
>> > https://pythonhow.com/python-tutorial/flask/web-development-with-
python-
>> and-flask/
>> > 
>> > - Do you know any other websites to deploy a python web application??
>> > 
>> > - No time to switch from Excel to anywhere else. Please do not make
>> > any changes to the Excel file.
>> > 
>> > - Tutorials and repositories of the web for such problems are also
>> > required. The same is required for python (flask, Django...) also.
>> Sorry did not spot that this was a homework assignment data should
>> still be imported into a DB (a trivial task) It can be exported back to
>> a compatible format just as easily if hard copy output is required
>> 
>> 
>> 
>> 
>> --
>> "Rembrandt's first name was Beauregard, which is why he never used it."
>> -- Dave Barry
> 
> 
> 
> As written no time to switch from excel to anywhere else but if a
> certain database is required to make changes in Excel’s cell values then
> which database to use (example Access or what) and after the right
> selection of the database, how to import data to a database and then
> export back to a compatible format that is to Excel cells….
> 
> I mean how to do this written below:
> 
> “data should still be imported into a DB (a trivial task) it can be
> exported back to a compatible format just as easily if hard copy output
> is required”
> 
> The reason I have written:
> 
> “What to write on GitHub or on google search to find the necessary code
> to start with? “
> 
> I will also be requiring a code to start with just as most people do.
> The same is the case with tutorials.
> 
> This is not homework and I have been checking openpyxl for the last one
> or two months to find what is required by me when I found nothing of
> what is required by me then posted on this google group.

1st save the data from excel as a csv file

you will find the csv module makes these much easier to deal with, even if 
you do not import into a db (although even then I would import into sql-
lite just for the benefits of the search algorithms)




-- 
Sometime in 1993 NANCY SINATRA will lead a BLOODLESS COUP on GUAM!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What to write or search on github to get the code for what is written below:

2022-01-07 Thread alister via Python-list
On Thu, 6 Jan 2022 10:55:30 -0800 (PST), NArshad wrote:

> All this is going to be in python’s flask and HTML only
> 
> 1. First, I have to check in the Excel sheet or table whether the book
> user has entered is present in the book bank or not.
> 
Excel is the wrong application for storing this data - it should be in a 
database

> 2. If a book is present and the quantity of the required book is greater
> than 0 (COPIES_LEFT column in excel file) and if the user wants the
> book, it will be assigned to the user which he will take from the book
> bank physically. When COPIES_LEFT will is less than or equal to 0 the
> message will be “Book finished or not present”.
Again Excel is not the correct application for processing this data
> 
> 3. The quantity of the book in the Excel file will be reduced by 1 in
> the COPIES_LEFT column and the name of the borrower or user will be
> entered/added in the Excel file table or sheet already made and the
> column name is BORROWER’S NAME.
> 
Database!
> 4. The borrower’s or user name can be more than one so they will be
> separated with a comma in the Excel file BORROWER’S NAME column.
> 
Database
> 
> - All functions mentioned above are to be deployed on the website
> pythonhow.com so make according to
> https://pythonhow.com/python-tutorial/flask/web-development-with-python-
and-flask/
> 
> - Do you know any other websites to deploy a python web application??
> 
> - No time to switch from Excel to anywhere else. Please do not make any
> changes to the Excel file.
> 
> - Tutorials and repositories of the web for such problems are also
> required. The same is required for python (flask, Django...) also.

Sorry did not spot that this was a homework assignment
data should still be imported into a DB (a trivial task) It can be 
exported back to a compatible format just as easily if hard copy output is 
required




-- 
"Rembrandt's first name was Beauregard, which is why he never used it."
-- Dave Barry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The task is to invent names for things

2021-10-29 Thread alister via Python-list
On Thu, 28 Oct 2021 00:38:17 +, Eli the Bearded wrote:

> In comp.lang.python, Peter J. Holzer  wrote:
>  ^^
> 
> Those all work. But if you are writing a new web framework and you name
> your method to log stuff to a remote server "Britney" because you were
> listening the singer, that's not perfectly fine, even you want to make
> "Oops, I did it again" jokes about your logged errors.

Although Oops would be aq pretty reasonable name for a logger or error 
handler... 
> 
> 
> Elijah --
> naming is hard, unless it's easy





-- 
After a number of decimal places, nobody gives a damn.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The task is to invent names for things

2021-10-29 Thread alister via Python-list
On Thu, 28 Oct 2021 00:41:41 +0200, Peter J. Holzer wrote:

> On 2021-10-27 12:41:56 +0200, Karsten Hilbert wrote:
>> Am Tue, Oct 26, 2021 at 11:36:33PM + schrieb Stefan Ram:
>> > xyzzy = lambda x: 2 * x
>> >   . Sometimes, this can even lead to "naming paralysis", where one
>> >   thinks excessively long about a good name. To avoid this naming
>> >   paralysis, one can start out with a mediocre name. In the course of
>> >   time, often a better name will come to one's mind.
>> 
>> In that situation, is it preferable to choose a nonsensical name over a
>> mediocre one ?
> 
> I don't know. A mediocre name conveys at least some information, and
> that seems to be better than none. On the other hand it might be just
> enough to lead the reader astray which wouldn't happen with a
> non-sensical name.
> 
> But since perfect names are hard to find, using nonsensical instead of
> mediocre names would mean choosing nonsensical names most of the time.
> So I'll stick with mediocre names if in doubt.
> 
> hp

Although if a mediocre name is chosen there is less impetus on the 
programmer to change it, "its not great but it'll do"
where as a nonsense name sticks out like a saw thumb until it is 
corrected.
I am firmly undecided




-- 
Riches cover a multitude of woes.
-- Menander
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread alister via Python-list
On Tue, 21 Sep 2021 14:22:52 -0500, Michael F. Stemper wrote:

> On 21/09/2021 13.49, alister wrote:
>> On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:
>> 
>>> On the prolog thread, somebody posted a link to:
>>> 
>>>
>>> One thing that it tangentially says is "XML is not the answer."
>>>
>>> I read this page right when I was about to write an XML parser to get
>>> data into the code for a research project I'm working on.
>>> It seems to me that XML is the right approach for this sort of thing,
>>> especially since the data is hierarchical in nature.
>>>
>>> Does the advice on that page mean that I should find some other way to
>>> get data into my programs, or does it refer to some kind of
>>> misuse/abuse of XML for something that it wasn't designed for?
>>>
>>> If XML is not the way to package data, what is the recommended
>>> approach?
>> 
>> 1'st can I say don't write your own XML parser, there are already a
>> number of existing parsers that should do everything you will need. 
>> This is a wheel that does not need re-inventing.
> 
> I was going to build it on top of xml.etree.ElementTree
> 
so not writing a parser, using one, that's ok

>> 2nd if you are not generating the data then you have to use whatever
>> data format you are supplied
> 
> It's my own research, so I can give myself the data in any format that I
> like.
> 
>> as far as I can see the main issue with XML is bloat, it tries to do
>> too many things & is a very verbose format, often the quantity of
>> mark-up can easily exceed the data contained within it.
>> 
>> other formats such a JSON & csv have far less overhead, although again
>> not always suitable.
> 
> I've heard of JSON, but never done anything with it.
the python json library makes it simple.
it was originally invented for javascript, it looks very much like the 
repl for a list/dictionary but if you are using std libraries you don't 
really need to know except for academic interst
> 
> How does CSV handle hierarchical data?
It dosn't, if you have heirachiacl data it is not a suitable format
> For instance, I have
> generators[1], each of which has a name, a fuel and one or more
> incremental heat rate curves. Each fuel has a name, UOM, heat content,
> and price. Each incremental cost curve has a name, and a series of
> ordered pairs (representing a piecewise linear curve).
> 
> Can CSV files model this sort of situation?
> 
>> As in all such cases it is a matter of choosing the most apropriate
>> tool for the job in hand.
> 
> Naturally. That's what I'm exploring.
> 
> 
> [1] The kind made of tons of iron and copper, filled with oil, and
> rotating at 1800 rpm.





-- 
Riches cover a multitude of woes.
-- Menander
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: XML Considered Harmful

2021-09-21 Thread alister via Python-list
On Tue, 21 Sep 2021 13:12:10 -0500, Michael F. Stemper wrote:

> On the prolog thread, somebody posted a link to:
> 
> 
> One thing that it tangentially says is "XML is not the answer."
> 
> I read this page right when I was about to write an XML parser to get
> data into the code for a research project I'm working on.
> It seems to me that XML is the right approach for this sort of thing,
> especially since the data is hierarchical in nature.
> 
> Does the advice on that page mean that I should find some other way to
> get data into my programs, or does it refer to some kind of misuse/abuse
> of XML for something that it wasn't designed for?
> 
> If XML is not the way to package data, what is the recommended approach?

1'st can I say don't write your own XML parser, there are already a 
number of existing parsers that should do everything you will need.  This 
is a wheel that does not need re-inventing.

2nd if you are not generating the data then you have to use whatever data 
format you are supplied

as far as I can see the main issue with XML is bloat, it tries to do too 
many things & is a very verbose format, often the quantity of mark-up can 
easily exceed the data contained within it.

other formats such a JSON & csv have far less overhead, although again 
not always suitable.

As in all such cases it is a matter of choosing the most apropriate tool 
for the job in hand. 

 




-- 
Antonym, n.:
The opposite of the word you're trying to think of.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:56:47 -0700, Mostowski Collapse wrote:

> What could be slow, repeatedly requesting the "args"
> field. Maybe I should do:
> 
> help = term.args i = 0 while i < len(help) - 1:
> mark_term(help[i])
> i += 1 term = help[i]
> 
No this construct is a common error in new python programmers
 the next progression they make is when they discover the range function
items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
for x in range(len(list)):
print (items[x])

but that is equally inefficient

the pythonic way is as previously suggested

for item in items:
print(item)

then the management of the index is being handled by the python 
interpreter internally & is effectively machine code.
every time you increment your own pointer the interpreter has to process 
reading the next line, reading the variable , incrementing it & then 
using it. this is what makes your current code slow. 

 
if you ever find your self creating a variable purely to use as a pointer 
into a list then you are almost certainly taking the wrong approach.

 more usefull links
https://www.youtube.com/watch?v=zdJEYhA2AZQ






-- 
"Show me a good loser, and I'll show you a loser."
-- Vince Lombardi, football coach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:48:18 -0700, Mostowski Collapse wrote:

> And how do you iterate over the first n-1 elements of a list with n
> elements? This is what my code does:
> 
> i = 0 while i < len(term.args) - 1:
> mark_term(term.args[i])
> i += 1 term = term.args[i]
> 
> You can try yourself:

use a slice
as a generic example you can try in the interactive interpreter (aka 
REPL):

>>>items = [1,2,3,4,5,6,7,8,9,0]
>>>for item in items[:-1]:
>>>print(item)

1
2
3
4
5
6
7
8
9

I should state for the record that I am no Python expert, I mainly visit 
this news group to learn.
sometimes from reading solutions & somtimes by trying to work out what 
the solution might be.

most productively by working out a solution & seeing if other posters 
agree (& working out why they don't)



-- 
The universe seems neither benign nor hostile, merely indifferent.
-- Sagan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 18:40:52 +, alister wrote:

> On Wed, 15 Sep 2021 11:31:48 -0700, Mostowski Collapse wrote:
> 
>> There is a further problem with this:
>> 
>>> for i,term in enumerate(term.args):
>>> mark_term(term.args[i])
>> 
>> It should read:
>> 
>> for i,help in enumerate(term.args):
>> mark_term(help)
>> 
>> But then i isn't need.
> even Better (i had only skimmed the code as I was certain I would find
> this, it is probably the No. 1 thing new python programmers get wrong if
> your example is correct the it can be simplified even further to
> 
> for help in term.args:
> mark_term(help)
> 
> & if help does not get used after this loop then a comprehension is even
> better _ == [mark_term(help) for help in term.args]
> 
> 
> the underscore character is python convention for an unneeded place-
> holder variable.
> 
> 
I also notice you are using match case - this was only introduced in 
python 10 so it is very new (i had not seen it before)
the break statements are probably not necessary as if ii understand this 
feature correctly python does not fall-through & execute every subsequent 
case after a successful match.

& finally the netiquette in this forum is to interleave of bottom post 
rather than top post, it makes it easier to follow the thread.
 




-- 
Don't quit now, we might just as well lock the door and throw away the 
key.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 11:31:48 -0700, Mostowski Collapse wrote:

> There is a further problem with this:
> 
>> for i,term in enumerate(term.args):
>> mark_term(term.args[i])
> 
> It should read:
> 
> for i,help in enumerate(term.args):
> mark_term(help)
> 
> But then i isn't need.
even Better (i had only skimmed the code as I was certain I would find 
this, it is probably the No. 1 thing new python programmers get wrong
if your example is correct the it can be simplified even further to

for help in term.args:
mark_term(help)

& if help does not get used after this loop then a comprehension is even 
better
_ == [mark_term(help) for help in term.args]


the underscore character is python convention for an unneeded place-
holder variable.

> 
> Mostowski Collapse schrieb am Mittwoch, 15. September 2021 um 20:22:50
> UTC+2:
>> Do you mean, replace this:
>> i = 0 while i < len(term.args) - 1:
>> mark_term(term.args[i])
>> i += 1 term = term.args[i]
>> 
>> By this:
>> 
>> for i,term in enumerate(term.args):
>> mark_term(term.args[i])
>> 
>> This wouldn't be correct anymore. The recursive call is only for the
>> arguments except for the last one one.
>> alister schrieb am Mittwoch, 15. September 2021 um 20:17:23 UTC+2:
>> > On Wed, 15 Sep 2021 18:23:10 +0200, Mostowski Collapse wrote:
>> > 
>> > > I really wonder why my Python implementation is a factor 40 slower
>> > > than my JavaScript implementation.
>> > > Structurally its the same code.
>> > > 
>> > > You can check yourself:
>> > > 
>> > > Python Version:
>> > > https://github.com/jburse/dogelog-moon/blob/main/devel/runtimepy/
>> > machine.py
>> > > 
>> > > JavaScript Version:
>> > > https://github.com/jburse/dogelog-moon/blob/main/devel/runtime/
>> > machine.js
>> > > 
>> > > Its the same while, if-then-else, etc.. its the same classes
>> > > Variable, Compound etc.. Maybe I could speed it up by some details.
>> > > For example to create an array of length n, I use in Python:
>> > > 
>> > > temp = [NotImplemented] * code[pos]
>> > > pos += 1
>> > > 
>> > > Whereas in JavaScript I use, also in exec_build2():
>> > > 
>> > > temp = new Array(code[pos++]);
>> > > 
>> > > So I hear Guido doesn't like ++. So in Python I use +=
>> > > and a separate statement as a workaround. But otherwise,
>> > > what about the creation of an array,
>> > > 
>> > > is the the idiom [_] * _ slow? I am assuming its compiled away. Or
>> > > does it really first create an array of size 1 and then enlarge it?
>> > > 
>> > > Julio Di Egidio wrote:
>> > 
>> > 
>> > this is probably a string contender
>> > 
>> > i = 0 while i < len(term.args) - 1:
>> > mark_term(term.args[i])
>> > i += 1 term = term.args[i]
>> > 
>> > try replacing with something more pythonic
>> > 
>> > for index,term in enumerate(term.args):
>> > mark_term(term.args[i])
>> > 
>> > 
>> > & possibly go all the way to changing it into a comprehension
>> > 
>> > there are other similar anti patterns throughout this code.
>> > 
>> > any time you are manually keeping a counter as an index into a
>> > list,tupple other iterable YOU ARE DOING IT WRONG!
>> > 
>> > Do not write javascript in python, write python
>> > 
>> > 
>> > 
>> > --
>> > Two percent of zero is almost nothing.
>> > 
>> > 
>> > 
>> > 
>> > --
>> > Whoever dies with the most toys wins.





-- 
Pie are not square.  Pie are round.  Cornbread are square.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Wed, 15 Sep 2021 18:23:10 +0200, Mostowski Collapse wrote:

> I really wonder why my Python implementation is a factor 40 slower than
> my JavaScript implementation.
> Structurally its the same code.
> 
> You can check yourself:
> 
> Python Version:
> https://github.com/jburse/dogelog-moon/blob/main/devel/runtimepy/
machine.py
> 
> JavaScript Version:
> https://github.com/jburse/dogelog-moon/blob/main/devel/runtime/
machine.js
> 
> Its the same while, if-then-else, etc.. its the same classes Variable,
> Compound etc.. Maybe I could speed it up by some details. For example to
> create an array of length n, I use in Python:
> 
>temp = [NotImplemented] * code[pos]
>pos += 1
> 
> Whereas in JavaScript I use, also in exec_build2():
> 
>temp = new Array(code[pos++]);
> 
> So I hear Guido doesn't like ++. So in Python I use +=
> and a separate statement as a workaround. But otherwise,
> what about the creation of an array,
> 
> is the the idiom [_] * _ slow? I am assuming its compiled away. Or does
> it really first create an array of size 1 and then enlarge it?
> 
> Julio Di Egidio wrote:


this is probably a string contender

i = 0
while i < len(term.args) - 1:
mark_term(term.args[i])
i += 1
term = term.args[i]

try replacing with something more pythonic

for index,term in enumerate(term.args):
 mark_term(term.args[i])


& possibly go all the way to changing it into a comprehension

there are other similar anti patterns throughout this code.

any time you are manually keeping a counter as an index into a list,tupple 
other iterable YOU ARE DOING IT WRONG!

Do not write javascript in python, write python



-- 
Two percent of zero is almost nothing.




-- 
Whoever dies with the most toys wins.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ANN: Dogelog Runtime, Prolog to the Moon (2021)

2021-09-15 Thread alister via Python-list
On Thu, 16 Sep 2021 03:26:39 +1000, Chris Angelico wrote:

> On Thu, Sep 16, 2021 at 3:17 AM Mostowski Collapse
>  wrote:
>>
>> I really wonder why my Python implementation is a factor 40 slower than
>> my JavaScript implementation.
>> Structurally its the same code.
>>
>>
> Very hard to know. Your code is detailed and complicated. Do they
> produce identical results? Are you using the same sort of floating-point
> data everywhere, or is one integer and the other float?
> What's going on with all the globals, the continuations, etc? My
> suspicion is that you're trying to write weird, wonky Python code, and
> then are surprised that it doesn't perform well.
> 
> ChrisA

And this demonstrates how an experienced Python programmer can make an 
almost spot on diagnosis without even checking the source code.

@ this stage I would recommend watching some presentations on you tube

this one https://www.youtube.com/watch?v=wf-BqAjZb8M by Raymond Hettinger 
is brilliant as it highlights there is more to checking code than just 
making sure it looks nice & runs correctly.



-- 
Lemmings don't grow older, they just die.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Friday Finking: Contorted loops

2021-09-12 Thread alister via Python-list
On Sun, 12 Sep 2021 10:11:15 +0200, jak wrote:

> -- snip --
>> 
>> An inconsistency that I have been able to notice is this:
>> someone suggests to remedy the absence of the do-while with:
>> while True:
>>   ...
>>   if condition:
>>   break
>> the problem arises if the while has an else of its own because the
>> break not only blocks the while loop but will also ignore the relative
>> else.
>> 
>> 
> I will try to make my doubt clearer:
> if the only way to terminate a 'while True' loop is by using the 'break'
> statement, why is it allowed to add the 'else' statement which will only
> contain dead code?
> 
> while True:
>  break
> else:
>  print('dead code')

Because adjusting the parser for one specific special case is not worth 
the effort.
it is not the job of the interpreter to sanitise stupid programming

"Special Cases aren't special enough the break the rules"




-- 
If you stew apples like cranberries, they taste more like prunes than
rhubarb does.
-- Groucho Marx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: on writing a while loop for rolling two dice

2021-09-07 Thread alister via Python-list
On Tue, 07 Sep 2021 14:53:29 +, Grant Edwards wrote:

> On 2021-09-06, Stefan Ram  wrote:
>> "Avi Gross"  writes:
>>> In languages like C/C++ there are people who make up macros like:
>>>#define INDEFINITELY_LOOP while (true)
>>>Or something like that and then allow the preprocessor to replace
>>>INDEFINITELY_LOOP with valid C code.
>>
>>   Those usually are beginners.
>>
>>>So, how to do something like that in python, is a challenge left to the
>>>user
>>
>>   Such a use of macros is frowned upon by most C programmers,
>>   because it renders the code unreadable.
> 
> I remember engineering manager I worked with about 35 years ago who used
> a set of C macros to try to make his code look as much like BASIC as
> possible:
> 
>   #define IF if ( #define THEN ) { #define ELSE } else {
>   #define ENDIF }
>   ...
> 
> IIRC he copied them out of a magazine article.
> 
> He then proceeded to try to implement a tree search algorithm (he didn't
> actually know that's what he was doing) using his new "language" without
> using recursion (which he had never heard of and couldn't grok) by
> keeping track of state using an array. It did not go well and made him a
> bit of a laughingstock. IIRC, he had first tried to write it in actual
> BASIC, but gave up on that before switching to C and his ridiculous
> macro set.

1 Simple rule, if you are programming in language 'a' then write Language 
'a' Code it.

Just because you can do something doesn't mean you should


-- 
Help!  I'm trapped in a Chinese computer factory!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to setup for localhost:8000

2019-07-07 Thread Alister via Python-list
On Sun, 07 Jul 2019 16:57:12 +, nabru wrote:

> jaymoyer44 [jaymoye...@gmail.com] wrote:
> 
>> On Thursday, April 14, 2016 at 1:47:03 PM UTC-4, wrh...@gmail.com
>> wrote:
>>> Hi,
>>> 
>>> I am working on window 7 and Python 3.5 to setup a localhost:8000 but
>>> it did not get through as shown below:
>>> > python -m http.server
>>> Serving HTTP on 0.0.0.0 port 8000 ...
>>> 
>>> But it did not show the results.
>>> 
>>> Can someone help me how to setup the localhost?
>>> 
>>> Thanks,
>>> Wen-Ruey
> 
> If it says 'serving HTTP...' try visiting localhost:8000 on your browser
> to see what happens.

failing that try showing your code so that we do not have to be psychic!



-- 
Nirvana?  That's the place where the powers that be and their friends 
hang out.
-- Zonker Harris
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (no subject)

2019-05-31 Thread Alister via Python-list
On Wed, 29 May 2019 08:07:06 +0530, Sri Tharun wrote:

> Why I am unable to install packages

because you are doing it wrong
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to split a list type array into float array?

2019-05-21 Thread Alister via Python-list
On Tue, 21 May 2019 03:38:43 -0700, Madhavan Bomidi wrote:

> Hi,
> 
> I have the following list type data:
> 
> ['  29.7963   29.6167   29.4371   29.2574   29.0778   28.8982   28.7185 
>  28.5389   28.3593   28.1797   28.   27.8204   27.6408   27.4611  
> 27.2815   27.1019   26.9223   26.7426   26.5630   26.3834   26.2037  
> 26.0241   25.8445   25.6649   25.4852   25.3056   25.1260   24.9463  
> 24.7667   24.5871   24.4075   24.2278   24.0482   -0.2616   -0.3215  
> -0.3813   -0.4412\n']
> 
> Can anyone help me split as a float array?
> 
> Thanks in advance

what have you tried ? (hint look up the docs on the spit method for 
strings)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The if is not working properly

2019-05-19 Thread Alister via Python-list
On Sun, 19 May 2019 20:29:35 +1000, Cameron Simpson wrote:

> On 18May2019 13:22, nobelio  wrote:
>>When you print the variable “a” it appears as True, but the program is
>>it is not getting in the if a==True:
> 
> It may be that "a" is not the Boolean value True but something else. But
> that is just a guess. Please reply and paste in a small example
> programme showing this problem.
> 
> Cheers,
> Cameron Simpson 

also if a==True is unnecessarily verbose
if a: would suffice
(unless you explicitly want True & not just a truthy value in which case 
use
if a is True:
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's the address for?

2019-02-18 Thread Alister via Python-list
On Mon, 18 Feb 2019 11:59:18 +, Stefan Ram wrote:

> When one prints a function, one might get something like:
> 
> 
> 
>   . The participants of my basic course asked me what the address is
>   for. I did not know.
> 
>   What's so important about the (presumed) address of a function that it
>   is shown on every stringification of each function?

it is the internal id of the function - Not necessarily an address, that 
is an implementation detail.

it is not intended for use within a program & has (almost) no practical 
use.



-- 
Microsoft Zen - Become one with the blue screen. 

   -- From a Slashdot.org post
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python program to phone?

2019-02-06 Thread Alister via Python-list
On Mon, 04 Feb 2019 15:20:58 -0500, Steve wrote:

> I have written my first python program (600 lines!) to help control my
> blood sugar and it has been so successful that my A1c dropped form 9.3
> to an impressive 6.4.  It will be much more useful if I had it on my
> phone. (MotoG, Android)  The .py file reads/writes to two txt files.
> 
> 
>  
> About a year ago, I installed Kivy and managed to transfer the "Hello
> World"
> app to my phone and it worked.  I am not on a different computer and
> believe that I got all the way through the installation but I do not see
> how to invoke it.  I am sure that I can go through the tutorial again
> and use my program instead.
> 
> 
>  
> How do I figure out what is wrong and might there ne a better way to get
> the program onto my phone?
> 
> 
>  
> Steve
> 
> 
>  
> P.S.  Yes, I tried to post this about two weeks ago but could not seem
> to respond to the replies I received.  I could contact one or two
> individuals but apparently not the masses.  How do I find out how this
> list works?
> 
> 
>  
> 
>  
> Foornote:
> There's 99 bugs in the code, in the code.
> 
> 99 bugs in the code.
> 
> Take one down and patch it all around.
> 
> Now there's 117 bugs in the code.

as a fellow diabetic I have to say well done
we use a different measure in the uk but i have managed to drop from an 
initial 107 (11.9) down to arround 39 (5.7)
6.4 is 46 which is still below the diabetic star point of 48

keep up the good work, sorry cant help with the phone question




-- 
If you are honest because honesty is the best policy, your honesty is 
corrupt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to replace space in a string with \n

2019-01-31 Thread Alister via Python-list
On Thu, 31 Jan 2019 10:18:20 +0100, ^Bart wrote:

> Hello everybody! :)
> 
> I got a text and I should replace every space with \n without to use
> str.replace,

Why?

> I thought something like this:
> 
> text = "The best day of my life!"
> 
> space = (' ')
> 
> if text.count(' ') in text:
>  space=\n
> 
> rightText = text-space
> 
>  print(rightText)
> 
> I should have an output like this:
> The best day of my life!





-- 
There is nothing new except what has been forgotten.
-- Marie Antoinette
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Exercize to understand from three numbers which is more high

2019-01-27 Thread Alister via Python-list
On Sun, 27 Jan 2019 15:59:42 +0100, ^Bart wrote:

>> You have got to a starting point - you have three numbers. Good.
>> 
>> Where do you do go from here?
>> 
>> I would start with two of the numbers, and work out which one is
>> higher.
> 
> # SOLVED!!!
> number1 = int( input("Insert the first number: "))
> 
> number2 = int( input("Insert the second number: "))
> 
> number3 = int( input("Insert the third number: "))
> 
> numbermax = number1
> 
> numbermiddle = number2
> 
> numbermin = number3
> 
> if number2 > number1 and number2 > number3:
>  numbermax = number2
> 
>  print("Number max is: ",numbermax)
> 
> if number1 > number2 and number1 > number3:
>  numbermax = number1
> 
>  print("Number max is: ",numbermax)
> 
> if number3 > number2 and number3 > number1:
>  numbermax = number3
> 
>  print("Number max is: ",numbermax)
> 
> if number2 < number1 and number2 < number3:
>  numbermin = number2
> 
>  print("Number min is: ",numbermin)
> 
> if number1 < number2 and number1 < number3:
>  numbermin = number1
> 
>  print("Number min is: ",numbermin)
> 
> if number3 < number2 and number3 < number1:
>  numbermin = number3
> 
>  print("Number min is: ",numbermin)
> 
>  numbermiddle = (number1+number2+number3)-(numbermax+numbermin)
> 
>  print("Number middle is: ",numbermiddle)
> 
> Maybe it's not the best way to do it but at this time in our course we
> should try to solve problems just by using few things like if, else,
> etc. I know there's also min or max but before to use them we must
> understand if else! :)
> 
>> Frank Millman
> 
> Thank you very much, you helped me to power on my brain! :D ^Bart

as a follow on exercise if you have covered them yet, convert your code 
into a function takes the 3 numbers as parameters. you will find as you 
progress it is a better way of structuring your program & increases 
flexibility.

good luck with your learning & congratulations on asking for assistance 
not simply a solution




-- 
 Zoidberg: Muy macho. Hey, gringos, here comes El Zoido to ruin 
   your drinking water! 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 3 random numbers

2019-01-15 Thread Alister via Python-list
On Tue, 15 Jan 2019 06:13:00 -0800, Gengyang Cai wrote:

> I managed to solve the problem and also another problem with different 3
> random numbers. But it wasn't a very good question in the first place, i
> admit 
> 
>
Indeed it is a poorly write exercise & I suspect it has been 
misinterpreted.

unless i am very much mistaken the tutor expects the program to pick the 
3 random numbers each time it is run, not the programmer  

-- 
We've picked COBOL as the language of choice.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are all items in list the same?

2019-01-08 Thread Alister via Python-list
On Tue, 08 Jan 2019 17:15:17 +, Alister wrote:

> On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote:
> 
>> 08.01.19 11:07, Peter Otten пише:
>>> Bob van der Poel wrote:
>>> 
 I need to see if all the items in my list are the same. I was using
 set()
 for this, but that doesn't work if items are themselves lists. So,
 assuming that a is a list of some things, the best I've been able to
 come up with it:

  if a.count( targ ) == len(a):

 I'm somewhat afraid that this won't scale all that well. Am I missing
 something?
>>> 
>>> a[1:] == a[:-1]
>>> 
>>> :)
>>> 
>>> 
>> Very clever! It is definitely the shortest solution.
> 
> would that still not return true if the list was a palindrome?
ignore me, just tried & ok




-- 
I'm not proud.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are all items in list the same?

2019-01-08 Thread Alister via Python-list
On Tue, 08 Jan 2019 16:48:58 +0200, Serhiy Storchaka wrote:

> 08.01.19 11:07, Peter Otten пише:
>> Bob van der Poel wrote:
>> 
>>> I need to see if all the items in my list are the same. I was using
>>> set()
>>> for this, but that doesn't work if items are themselves lists. So,
>>> assuming that a is a list of some things, the best I've been able to
>>> come up with it:
>>>
>>>  if a.count( targ ) == len(a):
>>>
>>> I'm somewhat afraid that this won't scale all that well. Am I missing
>>> something?
>> 
>> a[1:] == a[:-1]
>> 
>> :)
>> 
>> 
> Very clever! It is definitely the shortest solution.

would that still not return true if the list was a palindrome?



-- 
Every young man should have a hobby: learning how to handle money is
the best one.
-- Jack Hurley
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program to keep track of success percentage

2018-12-08 Thread Alister via Python-list
On Sat, 08 Dec 2018 10:02:41 -0800, Musatov wrote:

> I am thinking about a program where the only user input is win/loss. The
> program let's you know if you have won more than 31% of the time or not.
> Any suggestions about how to approach authoring such a program? Thanks.

To start describe how you would do it if keeping score on paper.

a simple loop
keep a count of the number for questions
keep a count of the number.
calculate the percentage.

once you have what is known as pseudo code you will be 90% of the way 
there
(python is effectively executable pseudo code anyway)

this should be more than enough to help you with you homework without 
doing it for you




-- 
If reporters don't know that truth is plural, they ought to be lawyers.
-- Tom Wicker
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to match list members in py3.x

2018-11-25 Thread Alister via Python-list
On Sun, 25 Nov 2018 08:49:03 -0800, Muhammad Rizwan wrote:

> On Sunday, 25 November 2018 10:59:46 UTC-5, Alister  wrote:
>> On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote:
>> 
>> > for each word in each line how can we check to see if a word is
>> > already present in a list and if it is not how to append that word to
>> > a new list
>> 
>> the 1st step is to stay awake in class & listen to your instructor,
>> then try to apply the principle involved
>> 
>> We don't do homework for you
>> 
>> when you have produced a program of you own (not necessarily working)
>> if you post it here then we will be more than happy to provide
>> constructive criticism
>> 
>> 
>> 
>> 
>> --
>> "Show business is just like high school, except you get paid."
>> - Martin Mull
> 
> IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART
> ASS.

with an attitude like that I will go one better & ignore ALL your posts



-- 
Good news.  Ten weeks from Friday will be a pretty good day.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to match list members in py3.x

2018-11-25 Thread Alister via Python-list
On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote:

> for each word in each line how can we check to see if a word is already
> present in a list and if it is not how to append that word to a new list

the 1st step is to stay awake in class & listen to your instructor, then 
try to apply the principle involved

We don't do homework for you

when you have produced a program of you own (not necessarily working) if 
you post it here then we will be more than happy to provide constructive 
criticism




-- 
"Show business is just like high school, except you get paid."
- Martin Mull
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-10-13 Thread Alister via Python-list
On Fri, 12 Oct 2018 09:12:03 -0700, Rob Gaddi wrote:

> On 10/11/2018 11:29 PM, Kaan Taze wrote:
>> Hi everyone,
>> 
>> Since this is my first post to mail-list I'm kind of hesitant to ask
>> this question here but as many of you spend years working with Python
>> maybe some of you can guide me.
>> 
>> What I trouble with is not a logical error that exist on a program I
>> wrote.
>> It's the Python itself. Well, I'm 22 years old CS student -from Turkey-
>> and what they showed us at university was C Language and Java but I
>> mainly use C in school projects etc. So it's been few months that I
>> started to use Python for my personal side-projects. There are lots of
>> resources to learn language. I do what I need to do with Python too but
>> I was kinda shocked when I solve Python questions at Hackerrank. Even
>> with list comprehensions you can implement in very smart way to get
>> things done and easy. Iterations, string operations. The codes I see on
>> the Internet using basics in a very clever way which I couldn't come up
>> with the same solution if I tried to for some time. I do understand
>> this ways but coming from ANSI C makes it hard to see this flexibility.
>> I probably do things in a both inefficient and hard way in my projects.
>> 
>> How do I get used to this? Is this just another "practice, practice,
>> practice" situation? Anything you can recommend?
>> 
>> 
>> All the best.
>> 
>> Kaan.
>> 
>> 
> A) Yes, it's practice practice practice.
> 
> B) Don't get hung up on finding the clever solution.  Comprehensions and
> generators and lots of other things are great under some circumstances
> for making the code clearer and easier to read, but they too can become
> the hammer that makes everything look like a nail.  The most important
> thing is that your code is logical, clean, and easy to understand.  If
> it doesn't take full advantage of the language features, or if the
> performance isn't optimized to within an inch of its life, well so be
> it.

To re-enforce this someone much wiser than me wrote (& I a paraphrasing a 
bit)

It takes more skill to debug code than to write it so if you write code 
at the limits of your ability yo do not have the skills needed to debug 
it.

KISS - Keep It Simple Stupid



-- 
Even if you do learn to speak correct English, whom are you going to speak
it to?
-- Clarence Darrow
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Observations on the List - "Be More Kind"

2018-10-09 Thread Alister via Python-list
On Mon, 08 Oct 2018 12:46:48 -0700, Ethan Furman wrote:

> On 10/08/2018 07:43 AM, Rhodri James wrote:
> 
>> I appreciate that the moderators are volunteers, but they have official
>> power on this list.  Being volunteers doesn't mean that they can't get
>> it wrong, or that we shouldn't call them on it when they do.
> 
> I completely agree.
> 
>> They have got things wrong,
> 
> I completely disagree.
from my reading the general feeling in the community would not support 
this
> 
>> and I have called them on it.
> 
> Yes, you and a few others -- and nobody has actually talked (emailed) us
> directly, but rather talked *about* us on the list [1].
> 
>> The response has been... I'm trying not to say "patronising" because
>> I'm fairly sure it wasn't meant that way, but "I'm sorry you feel that
>> way" made me feel patronised.
> 
> You're right, I didn't mean it that way, and I apologize.
> 
> To briefly explain our decisions of late:
> 
> Suspending D'Aprano:
> ---
> His public post to me was shared with several people, including
> moderators of others lists, and it was unanimously agreed that his post
> was completely unacceptable and a two month suspension was appropriate.
> I restarted that suspension because, according to his own words, "I am
> ignoring the ban in this instance"; had he emailed me privately I would
> have correctly posted the notice to the list; had he not said that and
> just posted I would have fixed the filter and left the suspension alone
> (he posts from comp.lang.python).

after it be cam apparent that you had made an error, & the general 
feeling that the ban was a bit harsh it would have be far more beneficial 
to you reputation to have rescinded the ban on this occasion with a 
public warning regarding the claimed unacceptable behaviour.
as it was your response of I made a mistake so I am going to restart the 
ban simply makes you look like a petulant child, I am sorely tempted to 
kill file you now myself.

> 
> Suspending Mark Lawrence:
> 
> He has a history of posting attacks.  I sent him a private warning, he
> responded a couple days later with another attack.
> 
> Suspending BartC:
> 
> Many, if not most, of his posts' primary relation to Python was how his
> personal language was better.  The resulting threads seemed to be
> largely unfriendly, unproductive, and unnecessary.
> 
> Banning Rick Johnson:
> 
> Hopefully no explanation needed [2].
> 
> Shutting down threads:
> -
> There is a problem with threads getting heated and people not exercising
> self-control and posting inappropriately.  That makes the list
> unwelcoming.  As soon as we feel that that is happening we are going to
> shut down the thread.  Personal attacks and name-calling are not
> appropriate and will not be tolerated.  The goal is not to shut down
> debate -- as long as the debate stays civil it will get no moderation
> action.  If a thread is shut down and you feel there is more to be
> (civilly) said -- wait a couple days so everyone can cool off, and then
> start a new thread.
> 
> Hopefully you now agree with our decisions, or at least support us in
> them.  If you don't, I actually am sorry -- I would much rather have
> your support (and everyone's).  Either way, we are not changing our
> minds about them.
> 
> --
> ~Ethan~
> Python List Moderator
> 
> 
> 
> [1] Please correct me if I'm wrong.
> 
> [2] If one is needed: his posts can contain profanity, personal attacks,
> condescension, and completely inappropriate language.





-- 
What about WRITING it first and rationalizing it afterwords?  :-)
 -- Larry Wall in <8...@jpl-devvax.jpl.nasa.gov>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST

2018-10-06 Thread Alister via Python-list
On Sat, 06 Oct 2018 21:56:09 +0200, Thomas Jollans wrote:

> On 06/10/2018 20:10, eliteanarchyra...@gmail.com wrote:
>> # - THIS LINE IS WHERE I NEED HELP  # ( if 2, 3, 4, 6 in list:
>> )
>>  print("you can roll again")
>> else:
>>  print("you have all 1's and 5's in your result")
>> 
>> 
> You can use a loop:
> 
> for good_number in [2,3,4,6]:
>  if good_number in result:
>  print("you can roll again")
>  break
> else:
>  print("you have all 1's and 5's in your result")

or simply check for 1 & 5 to exit otherwise continue



-- 
Someone hooked the twisted pair wires into the answering machine.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1.

2018-10-04 Thread Alister via Python-list
On Thu, 04 Oct 2018 09:44:01 +0100, Tony van der Hoff wrote:

> On 04/10/18 09:31, Alister via Python-list wrote:
>> On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote:
>> 
>>> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie
>>> wrote:
>>>> On 10/03/2018 09:26 AM, Musatov wrote:
>>>>> I don't even know where to begin! (I'm reading the Dummies book)
>>>>
>>>> If you have no experience in computer programming, it's going to be a
>>>> steep learning curve.
>>>>
>>>> But your first step is to learn Python and how to write programs in
>>>> it.
>>>> That book and others will help with that.  You'll have to write lots
>>>> of simple programs unrelated to primes along the way that help you
>>>> understand programming concepts.
>>>>
>>>> If you already have experience in other languages, the task will be
>>>> easier.
>>>>
>>>> Computer programming is quite natural to some (small children seem to
>>>> get it much easier than us adults), but I've seen others struggle to
>>>> grasp the abstract concepts for years.
>>>>
>>>> Once you've grasped basic Python programming, you can return top the
>>>> original problem at hand.  Start by identifying the process or
>>>> algorithm that would find these primes. In other words, how would you
>>>> do it on pen and paper?  Computer programs are not magic.  They are
>>>> only expressions of human thinking. Often some very smart
>>>> mathematicians have come up with powerful algorithms (a step-by-step
>>>> process) to do these things,
>>>> and your job as a programmer is to turn this mathematical process
>>>> into a computer program using things like loops and Boolean logic.
>>>> How would you find these primes using your pen, paper, and
>>>> calculator?
>>>
>>> Literally, how I found them was taking a list of primes and checking
>>> if the calculations with the lesser primes resulted in numbers also
>>> further along on the list.
>>>
>>> Another way I guess would be to do the calculations then check if the
>>> number is prime.
>> 
>> That is exactly how you do it with in a program.
>> 
>> create a loop & check to see if the target number can be divided by
>> each possible divisor in turn .
>> for large numbers this will take a large number of tests (hey that is
>> why you have the computer do them, it is faster than you & does not get
>> bored ;-) ) there are numerous tricks for speeding up this process once
>> you have the basic working.
>> 
>> start by testing small numbers & then use your real data once you have
>> something that works
>> 
>> as a starter a simple loop in python could be as follows
>> 
>> for x in xrange(10):
>>  print x
>> 
>> once you have an outline of a program post it back here if things dont
>> work as expected
>> 
>> 
> Two lines, two errors! To save the noob a lot of head-scratching, that
> should be:
> for x in range(10):
> 
> If you're running python 3, as you should do for any new project:
>   print( x )

perfectly legit python 2.7
I probably should have considered writing python 3 compatible code but 
range operates differently on the 2 versions & would be a poor choice for 
python 2 when numbers get larger

ass for the head scratching a noob (& anyone else for that mater) far 
more from correcting code than they do from simply copy & pasting working 
code.




-- 
TAILFINS!! ... click ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program to find Primes of the form prime(n+2) * prime(n+1) - prime(n) +- 1.

2018-10-04 Thread Alister via Python-list
On Wed, 03 Oct 2018 09:43:07 -0700, Musatov wrote:

> On Wednesday, October 3, 2018 at 11:12:43 AM UTC-5, Michael Torrie
> wrote:
>> On 10/03/2018 09:26 AM, Musatov wrote:
>> > I don't even know where to begin! (I'm reading the Dummies book)
>> 
>> If you have no experience in computer programming, it's going to be a
>> steep learning curve.
>> 
>> But your first step is to learn Python and how to write programs in it.
>> That book and others will help with that.  You'll have to write lots of
>> simple programs unrelated to primes along the way that help you
>> understand programming concepts.
>> 
>> If you already have experience in other languages, the task will be
>> easier.
>> 
>> Computer programming is quite natural to some (small children seem to
>> get it much easier than us adults), but I've seen others struggle to
>> grasp the abstract concepts for years.
>> 
>> Once you've grasped basic Python programming, you can return top the
>> original problem at hand.  Start by identifying the process or
>> algorithm that would find these primes. In other words, how would you
>> do it on pen and paper?  Computer programs are not magic.  They are
>> only expressions of human thinking. Often some very smart
>> mathematicians have come up with powerful algorithms (a step-by-step
>> process) to do these things,
>> and your job as a programmer is to turn this mathematical process into
>> a computer program using things like loops and Boolean logic. How would
>> you find these primes using your pen, paper, and calculator?
> 
> Literally, how I found them was taking a list of primes and checking if
> the calculations with the lesser primes resulted in numbers also further
> along on the list.
> 
> Another way I guess would be to do the calculations then check if the
> number is prime.

That is exactly how you do it with in a program.

create a loop & check to see if the target number can be divided by each 
possible divisor in turn
.
for large numbers this will take a large number of tests (hey that is why 
you have the computer do them, it is faster than you & does not get 
bored ;-) ) there are numerous tricks for speeding up this process once 
you have the basic working.

start by testing small numbers & then use your real data once you have 
something that works

as a starter a simple loop in python could be as follows

for x in xrange(10):
print x

once you have an outline of a program post it back here if things dont 
work as expected



-- 
A narcissist is someone better looking than you are.
-- Gore Vidal
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's an elegant way to test for list index existing?

2018-09-30 Thread Alister via Python-list
On Sun, 30 Sep 2018 11:45:21 +0100, Bart wrote:

> On 30/09/2018 11:14, Chris Green wrote:
>> Chris Angelico  wrote:
>>> On Sat, Sep 29, 2018 at 12:21 PM Chris Green  wrote:

 I have a list created by:-

  fld = shlex.split(ln)

 It may contain 3, 4 or 5 entries according to data read into ln.
 What's the neatest way of setting the fourth and fifth entries to an
 empty string if they don't (yet) exist? Using 'if len(fld) < 4:'
 feels clumsy somehow.
>>>
>>> shlex.split(ln) + ["", ""]
>>>
>> Now that *is* neat, I will probably do this.
> 
> Won't it give you 7 entries, when shlex.split(ln) returns 5?
> 
> Or doesn't that matter? (In which case that's something not mentioned in
> the specification.)

if only 5 entries are required than simply prune off the extra using a 
slice as I suggested yesterday



-- 
 DalNet is like the special olympics of IRC.  There's a lot of
   drooling goin' on and everyone is a 'winner'.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What's an elegant way to test for list index existing?

2018-09-29 Thread Alister via Python-list
On Fri, 28 Sep 2018 19:00:29 +0100, Chris Green wrote:

> I have a list created by:-
> 
> fld = shlex.split(ln)
> 
> It may contain 3, 4 or 5 entries according to data read into ln. What's
> the neatest way of setting the fourth and fifth entries to an empty
> string if they don't (yet) exist? Using 'if len(fld) < 4:' feels clumsy
> somehow.

how about simply
adding 2 or more null entries to the list then slicing?

string = "a b c"
a=string.split()
(a+['',''])[0:5]







-- 
QOTD:
If you're looking for trouble, I can offer you a wide selection.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Experiences with a programming exercise

2018-09-15 Thread Alister via Python-list
On Sat, 15 Sep 2018 17:08:57 +, Stefan Ram wrote:

> I gave two different functions:
> 
> def triangle():
> for i in range( 3 ):
> forward( 99 ); left( 360/3 )
> 
> def rectangle()
> for i in range( 4 ):
> forward( 99 ); left( 360/4 )
> 
>   , and the exercise was to write a single definition for a function
>   »angle( n )« that can be called with »3« to paint a triangle and with
>   »4« to paint a rectangle. Nearly all participants wrote something like
>   this:
> 
> def angle( n ):
> if n == 3:
> for i in range( 3 ):
> forward( 99 ); left( 360/3 )
> if n == 4:
> for i in range( 4 ):
> forward( 99 ); left( 360/4 )
> 
>   Now I have added the requirement that the solution should be as short
>   as possible!

seems a good exercise & you are breaking the students in step by stem 
which is also good
get something that works, then make it better

i would suggest instead of the new requirement to be make it a short as 
possible make it work with ANY number of sides.




-- 
Max told his friend that he'd just as soon not go hiking in the 
hills.
Said he, "I'm an anti-climb Max."
[So is that punchline.]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sending file to the user gives UnicodeEncodeError in Flask framework

2018-09-12 Thread Alister via Python-list
On Wed, 12 Sep 2018 06:57:36 -0700, Νίκος Βέργος wrote:

> I want to send the user a file when he clicks the appropriate button and
> I'm suing the following.
> 
>   # Prepare selected file for download...
>   send_file( '/home/nikos/wsgi/static/files/' + filename )
> 
> But no matter what file the usser selects iam always receiving this
> response.
> 
> 
> [Wed Sep 12 14:10:48.450211 2018] [wsgi:error] [pid 5172] [remote
> 46.103.174.201:14089]   File "/home/nikos/wsgi/downloads.py", line
> 182, in file [Wed Sep 12 14:10:48.450214 2018] [wsgi:error] [pid
> 5172] [remote 46.103.174.201:14089] send_file(
> '/home/nikos/wsgi/static/files/' + filename )
> [Wed Sep 12 14:10:48.450219 2018] [wsgi:error] [pid 5172] [remote
> 46.103.174.201:14089]   File
> "/usr/lib/python3.6/site-packages/flask/helpers.py", line 592, in
> send_file [Wed Sep 12 14:10:48.450221 2018] [wsgi:error] [pid 5172]
> [remote 46.103.174.201:14089] file = open(filename, 'rb')
> [Wed Sep 12 14:10:48.450237 2018] [wsgi:error] [pid 5172] [remote
> 46.103.174.201:14089] UnicodeEncodeError: 'ascii' codec can't encode
> characters in position 30-39: ordinal not in range(128)
> 
> 
> How will I be able to send the selected file to the user?

try providing enough code for people to reproduce the problem & you may 
get some assistance although i suspect many posters may believe you to be 
a previous poster (also called Nicos) who was a disaster looking for 
somewhere to happen, if that is not you then I would also suggest you try 
reading https://www.biostars.org/p/75548/



-- 
"Free markets select for winning solutions."
-- Eric S. Raymond
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: (new try) - Running a second wsgi script from within the first wsgi script

2018-09-10 Thread Alister via Python-list
On Sun, 09 Sep 2018 18:47:49 -0700, Νίκος Βέργος wrote:

> I have 3 wsgi scripts listening on 3 locations. What i'm trying to run
> an wsgi script from within another wsgi script with the following
> statement.
> 
> page = 'clientele'
> pdata = requests.get( 'http://superhost.gr/' + page )
> pdata = pdata.text + counter page = the location of another wsgi app.
> 
> The error i'am getting when for i.e i try to load
> http://superhost.gr/clientele
> 
> mod_wsgi (pid=7152): Exception occurred processing WSGI script
> '/home/nikos/public_html/app.py'
> OSError: Apache/mod_wsgi failed to write response data: Broken pipe.
> The other script by itself executes normally but NOT from within my
> app.py script.
> 
> Any ideas on how to execute a wsgi app (b) from within a wsgi app(a) and
> store the response as html data?

repeatedly asking the same question will not get you answered any faster
in fact it may simply get you black-listed by many posters



-- 
Why are you so hard to ignore?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: using python's logo in your own logo

2018-08-09 Thread Alister via Python-list
On Thu, 09 Aug 2018 12:13:07 +0400, Abdur-Rahmaan Janhangeer wrote:

> in short,
> 
> can you use python's logo in your own logo without credit?
> 
> yours,
> 
> Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius

I would expect the answer to that to be a big NO.
I am pretty sure you would need to get permission.



-- 
VICARIOUSLY experience some reason to LIVE!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test for absence of infinite loop

2018-07-17 Thread Alister via Python-list
On Tue, 17 Jul 2018 10:10:49 +0100, Robin Becker wrote:

> A user reported an infinite loop in reportlab. I determined a possible
> cause and fix and would like to test for absence of the loop. Is there
> any way to check for presence/absence of an infinite loop in python? I
> imagine we could do something like call an external process and see if
> it takes too long, but that seems a bit flaky.

google halting problem & you will see that this is an impossible request



-- 
I hate quotations.
-- Ralph Waldo Emerson
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using Python with a website

2018-07-05 Thread Alister via Python-list
On Wed, 04 Jul 2018 23:25:14 +, Adrian Taylor wrote:

> G'day All,
> 
> I have just discovered Python and thanks to a script by Ethan I can read
> a foxpro database and change the required values.
> However my next big step is to be able to use this python feature within
> a website.
> 
> Basically I want to be able to click on a button and call the script.
> This would in turn display some information on the webpage but do what
> it needs to do on the server.
> I have setup Apache and it all works on the server, my stumbling block
> is calling it from a website.
> 
> I am using Server 2012 R2 Python 3.7 Apache 2.4 I can run the Python
> scripts from the command line prompt.
> 
> Can anyone help?
> 
> Regards,
> Adrian Taylor InfoHub - ICT - Helpdesk
> 
> 
> 
> A : 5 Faith Avenue, Plainland , QLD 4341 T : 07 5466 9900 E :
> atay...@faithlc.qld.edu.au
> W : www.faithlc.qld.edu.au
> 
> [cid:image005.png@01D2CD7E.0F6F4710]
> 
> 
> 
> The information contained in this e-mail message and any attached files
> may be confidential information, and may also be the subject of legal
> professional privilege. If you are not the intended recipient any use,
> disclosure or copying of this e-mail is unauthorised. If you have
> received this e-mail in error, please notify the sender immediately by
> reply e-mail and delete all copies of this transmission together with
> any attachments.

start by looking up uwsgi




-- 
Sun in the night, everyone is together,
Ascending into the heavens, life is forever.
-- Brand X, "Moroccan Roll/Sun in the Night"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Something new which all programmers world wide will appreciate

2018-06-28 Thread Alister via Python-list
On Wed, 27 Jun 2018 14:30:15 -0700, Rob Gaddi wrote:

> On 06/27/2018 02:14 PM, skybuck2...@hotmail.com wrote:
>> Now I don't like the French much ! LOL.
>> 
>> But this time they have invented something which will fill programmers
>> with tears of joy ! =D
>> 
>> http://www.euronews.com/2018/06/27/pizza-making-robot
>> 
>> Hopefully this will lead to cheaper and delicious pizzas in the future
>> ! ;) =D
>> 
>> Bye,
>>Skybuck.
>> 
>> 
> Or, you know, someone didn't bother putting limit checks in and a time
> out of 20 the thing gets lost and starts putting the sauce directly on
> the customer.

as a diabetic the bread base puts them firmly on the bad list anyway :-(



-- 
"If it ain't broke, don't fix it."
- Bert Lantz
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python for beginners or not? [was Re: syntax difference]

2018-06-25 Thread Alister via Python-list
On Mon, 25 Jun 2018 11:42:27 +0100, Mark Lawrence wrote:

> On 25/06/18 10:10, Alister via Python-list wrote:
>> On Mon, 25 Jun 2018 11:36:25 +0400, Abdur-Rahmaan Janhangeer wrote:
>> 
>>> i think he means like for a loop to iterate over a list you might do
>>>
>>> list = [1,2,3]
>>> for i in range(len(list)):
>>>  print(list[i])
>>>
>>>
>>> but the you might as well go for the simpler :
>>>
>>>
>>> for elem in list:
>>>
>>>   print(elem)
>>>
>>> Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ
>>>
>>>
>>>
>>>
>> for i in range(len(list)): is a python anti-pattern it is almost a 100%
>> guarantee that you are doing something wrong*
>> 
>> *as with all rules of thumb there is probably at least 1 exception that
>> the python experts will now point out.
>> 
>> 
>> 
> The exception is that if you really do need the index, you write:-
> 
> for i, elem in enumerate(list):

I would not call that an exception, that is still the correct way to 
obtain the index during the loop




-- 
I saw a subliminal advertising executive, but only for a second.
-- Steven Wright
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python for beginners or not? [was Re: syntax difference]

2018-06-25 Thread Alister via Python-list
On Mon, 25 Jun 2018 11:36:25 +0400, Abdur-Rahmaan Janhangeer wrote:

> i think he means like for a loop to iterate over a list you might do
> 
> list = [1,2,3]
> for i in range(len(list)):
> print(list[i])
> 
> 
> but the you might as well go for the simpler :
> 
> 
> for elem in list:
> 
>  print(elem)
> 
> Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ
> 
> 
>

for i in range(len(list)): is a python anti-pattern it is almost a 100% 
guarantee that you are doing something wrong*

*as with all rules of thumb there is probably at least 1 exception that 
the python experts will now point out.


-- 
Lend money to a bad debtor and he will hate you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax difference

2018-06-21 Thread Alister via Python-list
On Wed, 20 Jun 2018 11:41:23 -0700, bart4858 wrote:

> The actual interpreter code is irrelevant. Switch would be a feature of
> the language being interpreted, not of the interpreter.
> 
> If the task is to match an expression X against a variety of values,
> then expressing that as a switch means the interpreter /could/ use a
> jump table (of labels within the byte code), rather than execute a chain
> of X==Y tests within byte code. So, evaluate X once then it could be a
> single byte code op.
> 
> At least, it will know that exactly the same X value is being tested. So
> you evaluate it once then keep it on the stack.
> 
> Think of Switch as another kind if hint.

which can be implemented in python by putting function calls as members 
of a list or dictionary

switch=[case1,case2,case3]
switch[a]()

(although i personally would still like to see a switch if anyone can 
come up with a suitable syntax that does not break the rest of the python 
philosophy wtr indentation.)



-- 
There are more things in heaven and earth,
Horatio, than are dreamt of in your philosophy.
-- Wm. Shakespeare, "Hamlet"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax difference

2018-06-20 Thread Alister via Python-list
On Tue, 19 Jun 2018 16:25:50 -0700, bart4858 wrote:

> Some of that can be done. It may not need specific support.
> 
> But my intention is to have an ordinary language for everyday coding not
> one that can only be understood by CS professors.
> 
> Mine is unusual in that I can drop features I rarely use, which means
> that everything in it gets good use. Including multi-level breaks.
> 
only because no one else is using your language & you do not have to 
worry about breaking the code of your userbase.

I think you are suffering from NIH* syndrome & are reinventing the wheel 
for no particular reason other than "Because you can"

> And the core language can stay small (or smallish - it's not Forth).
> Which I think is where we came in.

* Not Invented Here




-- 
To be a kind of moral Unix, he touched the hem of Nature's shift.
-- Shelley
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax difference

2018-06-20 Thread Alister via Python-list
On Wed, 20 Jun 2018 13:59:40 +, Grant Edwards wrote:

> On 2018-06-20, Alister via Python-list  wrote:
> 
>> Annotations were invented by the Nazi's on the explicit instruction of
>> Hitler.  there, can someone now invoke Godwins law & call this
>> discussion closed :-)
> 
> I'm pretty sure I read somewhere that Godwin's law doesn't apply when
> one invokes Hitler/Nazis for the purpose of stopping the thread...

damn protocol nazi




-- 
Pure drivel tends to drive ordinary drivel off the TV screen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax difference

2018-06-20 Thread Alister via Python-list
On Wed, 20 Jun 2018 03:13:09 +, Steven D'Aprano wrote:

> On Tue, 19 Jun 2018 12:13:40 -0700, Jim Lee wrote:
> 
>> On 06/19/2018 04:13 AM, Ed Kellett wrote:
>>> I think we're all--still--missing the larger point that "easy to
>>> remove" is a completely stupid metric for judging language features.
>>> Seriously. Not a little bit stupid.
>>
>> Not if you think of the feature as analogous to cancer.
> 
> That would take it so far beyond the stupidity event horizon that no
> human language has an adjective for how stupid it is.
> 
> Besides, annotations aren't cancer. They're obviously terrorism. Any
> fool can see that.

Annotations were invented by the Nazi's on the explicit instruction of 
Hitler.
there, can someone now invoke Godwins law & call this discussion 
closed :-)



-- 
Do what comes naturally.  Seethe and fume and throw a tantrum.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python list vs google group

2018-06-18 Thread Alister via Python-list
On Fri, 15 Jun 2018 09:32:05 -0700, T Berger wrote:

> On Friday, June 15, 2018 at 11:55:59 AM UTC-4, Chris Angelico wrote:
>> Perhaps quantity is not the important thing here.
> 
> It is the important thing. I'm stuck with a problem and still waiting
> for replies to my email. I've decided to repost my problem here, so
> we'll see whether my hypothesis holds water.
> 
> Tamara

i still beg to differ & agree with Chris. quality is what counts
which would you prefer 100 wrong/contradictory answers or one correct one*


* i accept that even here for any moderately complex question you are 
still likely to get contradictory answers



-- 
Iron Law of Distribution:
Them that has, gets.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scanner freakishness [was Re: Python list vs google group]

2018-06-16 Thread Alister via Python-list
On Sat, 16 Jun 2018 14:25:52 -0400, William Ray Wing wrote:

>> On Jun 16, 2018, at 9:10 AM, Steven D'Aprano
>>  wrote:
>> 
>> On Sat, 16 Jun 2018 11:54:15 +1000, Chris Angelico wrote:
>> 
>>> On Sat, Jun 16, 2018 at 11:00 AM, Jim Lee  wrote:
>> 
 I once had a Mustek color scanner that came with a TWAIN driver.  If
 the room temperature was above 80 degrees F, it would scan in color -
 otherwise, only black & white.  I was *sure* it was a hardware
 problem,
 but then someone released a native Linux driver for the scanner. 
 When I moved the scanner to my Linux box, it worked fine regardless
 of temperature.
 
 
>>> I would be mind-blown if I did not have the aforementioned too many
>>> hours. Sadly, I am merely facepalming. Wow.
>> 
>> 
>> 
> Let me add one more story (true) to the list.  Concerns an old IBM
> mainframe installed in a bank in New York City, that crashed rarely, and
> only night, never during the day.  They called IBM; repair man spent the
> night with it - no crash; same story the next night and the next. 
> Finally on the forth night he left around 10:00 PM to get something to
> eat and some coffee.  Came back to find the computer had crashed.  Spent
> the next night - no crash.  Left the next again for coffee, came back to
> find the computer down.  Obviously it was only crashing when he wasn't
> watching.  Next night he left, but only took the elevator down to the
> ground floor, didn’t go outside.  Computer crashed.  He rebooted,
> restarted the job stream, left the computer room for the same length of
> time, but didn’t leave the floor.  No crash.
> 
> To make a long story short, it was the motor-generator set that ran the
> elevators.  During the day, there was enough constant elevator traffic
> so that the MG set never shut down and even it it did, there was enough
> load elsewhere in the building to make the start-up transient a
> relatively small perturbation.  At night it would time out, shut down,
> and when he called for the elevator late at night, the start-up
> transient was too much for the computer’s power regulators.
> 
> Earlier crashes turned out to be coincident with janitorial staff
> working extra late after special events.
> 
> Bill
> 
My supervisor had a similar issue with a PBX (Telephone system) that 
would cut of callers when the lift was used.

I personally one attended a site to try to identify why an ISDN circuit 
kept randomly resetting.
I had been on the phone with the BT engineer for about 1/2 hr monitoring 
the circuit when it suddenly cut off.

"Was it anything I did" asked the person using the photo copier

A few quick tests later confirmed that whenever the photocopier made 
multiple copies (approx 10+) the circuit would reset
 
Cust advised to relocate photocopier, case closed :-)

or if you want a really strange one we used to maintain PBX's for a 
particular Bank.
A common fault report was the earpiece buzzing.
This turned out to be caused by blown halogen light bulbs in a nearby 
display board (i don't know who originally identified that one). working 
on the help desk it was always "fun" trying to convince the user that 
this was the problem, understandably they though we were pulling their 
leg"

 

> 
> 
>> --
>> Steven D'Aprano "Ever since I learned about confirmation bias, I've
>> been seeing it everywhere." -- Jon Ronson
>> 
>> --
>> https://mail.python.org/mailman/listinfo/python-list





-- 
It's later than you think.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Understanding memory location of Python variables

2018-06-16 Thread Alister via Python-list
On Sat, 16 Jun 2018 13:19:04 -0400, Joel Goldstick wrote:

> On Sat, Jun 16, 2018 at 12:38 PM,   wrote:
>> Hi everyone,
>>
>> I'm intrigued by the output of the following code, which was totally
>> contrary to my expectations. Can someone tell me what is happening?
>>
> myName = "Kevin"
> id(myName)
>> 47406848
> id(myName[0])
>> 36308576
> id(myName[1])
>> 2476000
>>
>> I expected myName[0] to be located at the same memory location as the
>> myName variable itself. I also expected myName[1] to be located
>> immediately after myName[0].
>> --
>> https://mail.python.org/mailman/listinfo/python-list
> 
> Others can probably give a more complete explanation, but small numbers,
> and apparently letters are cached since they are so common.

also ID is not necessarily a memory location (at least not according to 
the language specification)
the standard cpython implementation does user the memory location for an 
object's ID but this is an implementation detail
 
if you are tying to make use of ID in any way to manipulate computer 
memory your program is fundamentaly broken



-- 
Can you MAIL a BEAN CAKE?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax difference

2018-06-16 Thread Alister via Python-list
On Sat, 16 Jun 2018 12:01:16 -0700, Sharan Basappa wrote:

> Is there a difference between these prints. The first one looks a bit
> complex. So, why should it be used?
> 
> my_age = 35 # not a lie
> 
> print "my age %s." % my_age print "my age ", my_age
> 
> Output:
> %run "D:/Projects/Initiatives/machine learning/programs/five.py"
> my age 35.
> my age  35

in that example probably no difference - readability counts.
but if you want to display a slightly different message then you could 
the following

print "may age is %s years",% my_age

which is arguably nicer than
print "my age is",
print my_age,
print "Years"

& less error prone


you can of course expand this format with multiple insertions & even 
explicit formatting for specific data types.





-- 
It got to the point where I had to get a haircut or both feet firmly
planted in the air.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python list vs google group

2018-06-15 Thread Alister via Python-list
On Fri, 15 Jun 2018 08:28:38 -0700, T Berger wrote:

> I'm suspecting that posting to python google groups (this site) gets
> more responses than mailing to the python list. Am I correct? Also,
> contrary to what I read on the python list information sheet, what shows
> up in this forum does not match what comes into my inbox. I started a
> post here and then replied to a post from my inbox. That reply does not
> show up in this forum.
> 
> Tamara

it certainly seems to be the source of most SPAM
as such some users of this list/newsgroup call it what you like block all 
posts from google groups



-- 
One day I'll be dead and THEN you'll all be sorry.
(alt.fan.pratchett)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the "Unpacking Arguments List" rule?

2018-06-13 Thread Alister via Python-list
On Wed, 13 Jun 2018 14:21:53 +0800, sa...@caprilion.com.tw wrote:

> [Of the first part]
> line 19 is
>  action(progress=progress, *args)
> where the args is a tuple
>  args = (i, 3)
> and the function is defined as
>  def action(id, reps, progress):
> 
> In documents 4.7.2. Keyword Arguments, it says '''
>  def parrot(voltage, state='a stiff', action='voom', type='Norwegian
> Blue'):
>  ...
>  ...
>  but all the following calls would be invalid:
>  ...
>  parrot(voltage=5.0, 'dead')  # non-keyword argument after a keyword
> argument
>  ...
> '''
> 
> After unpack the args in line 19, it will be looks like
>  action(progress=progress, i, 3)
> and it seems violate the above rule.
> 
> [Of the second part]
>  > The "*args" and "**kw" are very helpfull. I hope (and expect)
>  > they will remain.
> There is no "**kw" involved in this topic:-) and the positional limit of
> "*args" in a function definitions has its own good reason:-)
> 
> IMHO, there is no reason to check the *args has to appear at last in
> positional argument list in a function call because of there is no
> "unknown number of parameters" at the time of unpacking. It should be
> alright to write line 19
>  action(*args, progress)

Anyone wanting to write such code should be banned form ever accessing a 
computer.
if you know how many arguments are going to be passed to match the *args 
part of this function then they should be assigned known variables 
otherwise the code will soon become an unmanageable mess.

this is why the language specifications states it should only appear 
after all known positional arguments have been declared
 
> just like assignment below where both are valid.
>  a, *b = any *a, b = any

> 
> Best Regards,
> Jach Fong
> 
> 
> dieter at 2018/6/13 PM 12:59 wrote:
>> Jach Fong  writes:
>>> ...
>>> 4.7.4. Unpacking Argument Lists The reverse situation occurs when the
>>> arguments are already in a list or tuple but need to be unpacked for a
>>> function call requiring separate positional arguments.
>>>  ...
>> args = [3, 6] list(range(*args))
>>> """
>>>
>>> I can't understand why line 19 works?
>> 
>> Not sure what "line 19" is - but if it refers to the example above:
>> 
>>"range" accepts (among others) 2 integer arguments.
>>The "*args" above means: unpack the sequence in "args" into
>>individual arguments.
>>This means (with the values of the example above),
>>that "range(*args)" is equivalent to "range(3, 6)".
>> 
>>> Didn't it violate the rule of "# non-keyword argument after a keyword
>>> argument"?
>> 
>> No keyword arguments at all in the above example.
>> 
>>> and why a more reasonable look syntax gets an error?
>>>
>>>  action(*args, progress)
>>>   ^
>>> SyntaxError: only named arguments may follow *expression  File
>>> "test.py", line 19
>> 
>> This is (in my view) a somewhat arbitrary restriction -- maybe
>> introduced for symmetry with the function definition syntax.
>> 
>> The message is quite clear, however: after the "*arg",
>> you must pass keyword arguments only, i.e. they must have the form
>> "param=value".
>> 
>>> The only reason I can guess is that it checks with the rule in 4.7.3
>>> which is really unrelated. The "*any" notation used in different
>>> places with different meaning, such as defining arbitrary argument,
>>> unpacking argument or even in an assignment(a,*b=any). Maybe it will
>>> be better to stop this syntax checking and lets both statements below
>>> valid:-)
>> 
>> The "*args" and "**kw" are very helpfull. I hope (and expect)
>> they will remain.
>> 
>> 
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus





-- 
I have a theory that it's impossible to prove anything, but I can't prove 
it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stefan's headers [was:Names and identifiers]

2018-06-11 Thread Alister via Python-list
On Mon, 11 Jun 2018 21:03:59 +0100, MRAB wrote:

> On 2018-06-11 20:17, Rick Johnson wrote:
>> On Monday, June 11, 2018 at 1:02:15 PM UTC-5, Chris Angelico wrote:
>> 
>>> You're trying to argue against my hypothetical statements about game
>>> publishing, and declaring that it's possible to use software to
>>> encourage hardware sales. But my point was that, absent copyright and
>>> the ability to make money from software, software probably *would not
>>> exist*. Tell me, do you go to a car manufacturer and buy the ability
>>> to use a third-party dashboard? If the dashboard itself is
>>> fundamentally unsaleable, and MUST be given away for free,
>>> who other than the original manufacturer will produce one?
>> 
>> A dashboard is a horrible analogy.
>> 
>> Software and hardware are connected at the _hip_.
>> 
>> A more correct analogy to describe the relationship between computer
>> hardware and computer software would be a car and an engine. A car is
>> basically useless without an engine,
>> and likewise for an engine without a car.
>> 
> I'm going to have to disagree with you there. The engine is also
> hardware. The software is more like the fuel.
> 
>> And yes, there are aftermarket engines sold by third parties and people
>> buy them all the time to replace OEM engines.
>> 
> It doesn't matter how good the engine is (or how much you've upgraded
> the processor), because without the fuel (or software) it's just a large
> paperweight (or room heater). :-)

its a bloody lousy room heater without the fuel to burn & generate heat



-- 
I want to be the white man's brother, not his brother-in-law.
-- Martin Luther King, Jr.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Data Integrity Parsing json

2018-04-26 Thread Alister via Python-list
On Wed, 25 Apr 2018 14:32:01 -0700, Sayth Renshaw wrote:

> Hi
> 
> Hoping for guidance trying to find some advanced articles or guides or
> topics for json parsing.
> 
> I can parse and extract json just dandy.
> 
> What I am trying to figure out is how I give myself surety that the data
> I parse out is correct or will fail in an expected way.
> 
> All the articles I search are just basic parsing tutorials.
> 
> Can you help with some advice or perhaps some saved away bookmarks you
> have that could be useful.
> 
> Cheers
> 
> Sayth

is there any reason you appear to be re-inventing the wheel rather than 
using the existing json module from the std library?



-- 
"Well, if you can't believe what you read in a comic book, what 
*___can*
you believe?!"
-- Bullwinkle J. Moose [Jay Ward]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Thank you Python community!

2018-03-20 Thread Alister via Python-list
On Mon, 19 Mar 2018 19:21:04 -0700, Rick Johnson wrote:

> On Monday, March 19, 2018 at 6:37:21 PM UTC-5, Ben Finney wrote:
> 
>> --
>>  \   "Success is going from one failure to the next without a loss
>>  |
>>   `\ of enthusiasm."  -- Winston Churchill
>>   |
>> _o__) 
>> |
>> Ben Finney
> 
> 
>> --
>>  \ “Experience is that marvelous thing that enables you to
>>  |
>>   `\   recognize a mistake when you make it again.” —Franklin P. Jones
>>   |
>> _o__) 
>> |
>> Ben Finney
> 
> Okay Ben, i believe it's time to come clean and finally admit to this
> fine community, that these quotes of yours are not merely chosen at
> random, but are in fact, delectable morsels of laser-focused sarcasm.

maybe not - I use fortune to generate mine & it can be supprisingly apt 
at times 



-- 
The primary function of the design engineer is to make things
difficult for the fabricator and impossible for the serviceman.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Style Q: Instance variables defined outside of __init__

2018-03-20 Thread Alister via Python-list
On Tue, 20 Mar 2018 08:52:29 +, Steven D'Aprano wrote:

> On Tue, 20 Mar 2018 02:43:13 -0400, Terry Reedy wrote:
> 
>> I think a claim that in all programs all attributes should be set *in*
>> __init__, as opposed to *during* initialization, is wrong.  All
>> attribute setting is side-effect from a functional view (and usually
>> 'bad' to a functionalist).  There is no reason to not delegate some of
>> it to sub-init functions when it makes sense to do do.  There is good
>> reason to do so when it makes the code easier to understand *and test*.
> 
> That is really well said Terry, thank you for articulating what I was
> thinking but couldn't find the words for.

but why would a functional programmer be programming an OOP class?




-- 
No one becomes depraved in a moment.
-- Decimus Junius Juvenalis
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: test

2018-03-12 Thread Alister via Python-list
On Mon, 12 Mar 2018 13:43:01 -0500, Yuan Xue wrote:

> test

failed



-- 
Mollison's Bureaucracy Hypothesis:
If an idea can survive a bureaucratic review and be implemented
it wasn't worth doing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bypassing firewall

2018-03-05 Thread Alister via Python-list
On Mon, 05 Mar 2018 08:37:14 +, Faruq Bashir wrote:

> How will i bypass web application firewall

For what purpose?
is this your firewall?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: py2exe output flagged as malware

2018-02-28 Thread alister via Python-list
On Wed, 28 Feb 2018 09:53:09 +, Robin Becker wrote:

> I see this has happened to others in the past. I'm using 32 bit python
> 2.7.10 with py2exe 3.3 on windows 7. The exes work fine,
> but when I try to download into windows 10 I'm getting the exes
> immediately removed as malware.
> 
> Is there any way to prevent this. It's very bad for python programs to
> get this kind of reputation.
> 
> Anyone know if the same happens with PyInstaller etc etc?

I would suggest you contact the Anti-virus vendor,
Are you sure you have download a clean copy of py2exe.



-- 
There are two ways to write error-free programs; only the third one works.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help me ?

2018-02-27 Thread alister via Python-list
On Mon, 26 Feb 2018 01:40:16 -0800, sotaro237 wrote:

> Define 2 lists. The first one must contain the integer values 1, 2 and 3
> and the second one the string values a, b and c. Iterate through both
> lists to create another list that contains all the combinations of the A
> and B elements. The final list should look like one of the 2 lists:
> 1. [1a, 1b, 1c, 2a, 2b, 2c, 3a, 3b, 3c]
> 2. [a1, a2. a3, b1, b2, b3, c1, c2, c3]
> BONUS: Make the final list contain all possible combinations : [1a, a1,
> 1b, b1, 1c, c1, 2a, a2, 2b, b2, 2c, c2, 3a, a3, 3b, b3, 3c, c3]
> 
> Help me !

Try staying awake in class where I am sure what you need would have been 
covered before the assignment was set
failing that try reading any of the python tutorials available on the 
internet




-- 
A career is great, but you can't run your fingers through its hair.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make Python run as fast (or faster) than Julia

2018-02-23 Thread alister via Python-list
On Fri, 23 Feb 2018 03:11:36 -0500, Terry Reedy wrote:

> On 2/22/2018 10:31 PM, Python wrote:
> 
>>> Why do you care about the 50 million calls? That's crazy -- the
>>> important thing is *calculating the Fibonacci numbers as efficiently
>>> as possible*.
> 
>> If you are writing practical programs, that's true.  But the Julia
>> benchmarks are not practical programs; they are designed to compare the
>> performance of various language features across a range of languages.
> 
> If that were so, then the comparison should use the fastest *Python*
> implementation.  Which is what the article discussed here did.  But the
> comparison is a lie when the comparison is compiled machine code versus
> bytecode interpreted by crippled cpython*.  And people use this sort of
> benchmark to choose a language for *practical programs*, and don't know
> that they are not seeing *Python* times, but *crippled cpython* times.

Benchmarks are completely pointless anyway.
the question when choosing a language should not be 'How fast it is', it 
should always be 'Is it fast enough'.
once you have a choice of languages that are fast enough other criteria 
for suitability become important (such as readability & ease of debugging)


-- 
If you're going to do something tonight that you'll be sorry for tomorrow
morning, sleep late.
-- Henny Youngman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Respam levels.

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 12:49:26 +, C W Rose wrote:

> Having run a check for straightforward spam, I now find that there's a
> site editing and reposting non-spam posts.  An example of the changed
> headers follows:
> 
> Original post headers:
>>
>> From c...@seckford.org Sun Feb 11 23:23:22 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-
mail
>> Message-ID: <4sd3le-ct4@tanner.seckford.org>
>> From: C W Rose 
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 + Lines: 49 Organization: None
>> Injection-Info: reader02.eternal-september.org;
>> posting-host="208e6410f66c7dd789dea67159b51bb7";
>>  logging-data="6406"; mail-complaints-to="abuse@eternal-
september.org";
>>  posting-account="U2FsdGVkX18su+yG7dqCpnqChqoPIY0JNXRwgNWzvcs="
>> User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX)
>> (Linux/3.10.79-gentoo-1 (i686))
>> Cancel-Lock: sha1:H7zOidR0ivbNjqiWUB6DSoMMYu8=
>> Xref: tanner.seckford.org comp.lang.python:139461
>> 
>> 
> Repost headers:
>>
>> From C Sun Feb 11 23:22:54 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!feeder.eternal-
september.org!aioe.org!news.bbs.geek.nz!.POSTED.agency.bbs.geek.nz!not-
for-mail
>> Message-ID: <847574...@f38.n261.z1.binkp.net>
>> From: C W Rose  (C W Rose)
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 +1200 Organization: fsxNet Usenet
>> Gateway | bbs.nz/#fsxNet Mime-Version: 1.0 Content-Type: text/plain;
>> charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info:
>> news.bbs.geek.nz;
>> posting-host="M6YmRdZYyc42DJk0lNlt/X4dpP4dzvceBNabSmESN3E";
>>  logging-data="24378"; mail-complaints-to="ab...@news.bbs.geek.nz"
>> User-Agent: VSoup v1.2.9.47Beta [95/NT]
>> X-MailConverter: SoupGate-Win32 v1.05 X-Comment-To: All Xref:
>> tanner.seckford.org comp.lang.python:139479
> 
> Looking at my current comp.lang.python news spool, 182 out of 683
> messages have been reposted by news.bbs.geek.nz; I haven't checked if
> they are all duplicates.  The reformatting of the body of message is to
> date trivial, just a reduction in line length.
> 
> This may be the result of a misconfigured spam filter, or an actual spam
> attack; anyway, I've now filtered news.bbs.geek.nz from my feed.
> 
> Will

many thanks for the effort 
/dev/null on my laptop is now almost full with this junk :-)



-- 
Let's do it.
-- Gary Gilmore, to his firing squad
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 13:42:08 +, Rhodri James wrote:

> On 13/02/18 13:11, Stanley Denman wrote:
>> I am trying to performance a regex on a "string" of text that python
>> isinstance is telling me is a dictionary.  When I run the code I get
>> the following error:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> Traceback (most recent call last):
>>File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in
>>
>>  x=MyRegex.findall(MyDict)
>> TypeError: expected string or bytes-like object
>> 
>> Here is the "string" of code I am working with:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> I want to grab the name "MILANI, JOHN C" and the last date
>> "-mm/dd/" as a pair such that if I have  X numbers of string like
>> the above I will end out with N pairs of values (name and date)/  Here
>> is my code:
>>   
>> import PyPDF2,re pdfFileObj=open('x.pdf','rb')
>> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
>> Result=pdfReader.getOutlines()
>> MyDict=(Result[-1][0])
>> print(MyDict)
>> print(isinstance(MyDict,dict))
>> MyRegex=re.compile(r"MILANI,")
>> x=MyRegex.findall(MyDict)
>> print(x)
> 
> As the error message says, re.findall() expects a string.  A dictionary
> is in no sense a string, so passing it in whole like that won't work.
> If you know that the name will always show up in the title field, you
> can pass just the title:
> 
>x = MyRegex.findall(MyDict['/Title'])
> 
> Otherwise you will have to loop through all the entries in the
> dictionary:
> 
>for entry in MyDict.values():
>  x = MyRegex.findall(entry) # ...and do something with x
> 
> I rather suspect you are going to find that the titles aren't in a very
> systematic format, though.

for what purpose are you trying to run this regex anyway?
it is almost certainly the wrong approach for your task



-- 
Larkinson's Law:
All laws are basically false.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google

2018-02-11 Thread alister via Python-list
On Sat, 10 Feb 2018 17:12:54 +1200, mm0fmf wrote:

> On 09/02/2018 21:05, codewiz...@gmail.com wrote:
>> On Friday, February 9, 2018 at 2:48:17 PM UTC-5, Chris Green wrote:
>>> codew...@gmail.com wrote:
 On Saturday, February 3, 2018 at 7:15:16 PM UTC-5, pyotr filipivich
 wrote:
> [snip]
>  Those of us who do not use google-groups may not notice the
>  loss
> of the google groupies.

 I use GG to read comp.lang.python because of the following
 combination of factors. I would definitely be happier if there was
 another way to do this, so that I wouldn't have to wade through lots
 of spam.

- I read it from both home and work.

- I can't install any additional software at work.

- There is no newsgroup reader software available at work.

- GG tracks read/unread status of every post. This is shared
  between work and home through my Google account.

- When I (very rarely) post from work, I can't
  do it by email, since outgoing email is blocked.

>>> Alternative approach, what I do:-
>>>
>>>  Run a text mode (but very capable and mouse aware) newsreader on
>>>  my home system, read news locally using that.
>>>
>>>  Use ssh (is that available at worK?) to connect from work to home
>>>  and run the same newsreader in the same environment. If you can't
>>>  even ssh from work then you can always use an 'ssh from the web'
>>>  app from your wenb browser.
>>>
>>> The newsreader I use is tin by the way.
>>>
>>> --
>>> Chris Green â·
>>
>> ssh would be even a bigger problem here. As I mentioned, I can't even
>> email from work to the outside! All web sites that provide remote
>> connectivity tools are blocked.
>>
>> Regards,
>> Igor.
>>
> If they take such restrictive practices then maybe should consider
> *just* doing your job when at work and leave the browsing to your own
> time?


I would also suggest that you consider the above statement ha snot been 
made out of malice but is trying to protect you.  if the restrictions are 
as strict as you say and you get seen you will probably loose your job.



-- 
Xerox does it again and again and again and ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "None" and "pass"

2018-02-06 Thread alister via Python-list
On Tue, 06 Feb 2018 08:55:35 +1100, Chris Angelico wrote:

> On Tue, Feb 6, 2018 at 8:39 AM, Ben Finney 
> wrote:
>> Chris Angelico  writes:
>>
>>> As one special case, I would accept this sort of code:
>>>
>>> def f():
>>> ...
>>>
>>> (three dots representing the special value Ellipsis)
>>>
>>> It's a great short-hand for "stub".
>>
>> I would not accept that.
>>
>> An even better way to write a stub function is to write a docstring:
>>
>> def frobnicate():
>> """ Frobnicate the spangule. """
>>
>> A docstring, like any bare expression, is also a valid statement.
>> Writing a docstring can be done immediately, because if you're writing
>> a stub function you at least know the external interface of that
>> function.
>>
>>
> This is true, but I'd rather have something _under_ the docstring if
> possible, and "..." works well for that. A docstring with nothing
> underneath doesn't look like a stub - it looks like a failed edit or
> something. Having a placeholder shows that it's intentional.
> 
> ChrisA

indeed and pass was implemented for precisely this usage
why even think about possible alternatives



-- 
Use an accordion.  Go to jail.
-- KFOG, San Francisco
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-03 Thread alister via Python-list
On Sun, 04 Feb 2018 06:49:57 +1100, Chris Angelico wrote:

> On Sun, Feb 4, 2018 at 6:34 AM, Mark Lawrence 
> wrote:
>> On 03/02/18 17:56, Peter J. Holzer wrote:
>>> You seem to confuse the mailing-list and the newsgroup. The
>>> mailing-list doesn't have a spam problem, and it is already (lightly)
>>> moderated.
>>>
>>> The newsgroup does have a spam problem (as well as a few other
>>> problems,
>>> like gmane mangling message-ids and breaking threads). Google groups
>>> is an interface to the newsgroup.
>>>
>>> There is a bi-directional gateway between them, but they aren't the
>>> same thing.
>>>
>>>  hp
>>>
>>>
>> No, they are one and the same thing, except that this is automatically
>> blocked by the numpty moderators, whereas some things that I state on
>> gg are passed, other things aren't.  It is quite clear that the
>> moderators are biased against people such as myself who are autistic
> 
> No, the moderators are biased against people who are constantly rude.
> Did you know that, autistic or not, you have the power to choose the
> tone of the words you type?
> 
> ChrisA

indeed my son is mildly autistic. I always explained to him that that 
diagnosis did not give him an excuse, it simply gave him an explanation 
of why things were harder for him.


-- 
If it's worth doing, it's worth doing for money.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Groups

2018-02-01 Thread alister via Python-list
On Thu, 01 Feb 2018 09:01:35 -0800, superchromix wrote:

> Our own programming discussion newsgroup, located at
> comp.lang.idl-pvwave, started receiving spam messages several months
> ago.
> 
> Two weeks ago, access to comp.lang.idl-pvwave was blocked by Google
> Groups.
> 
> When trying to access comp.lang.idl-pvwave, a message is now displayed,
> stating that the group owner needs to remove the spam, and can then
> apply to Google in order to have access reinstated.
> 
> However, old public Usenet groups like this have no owner.  The
> comp.lang.idl-pvwave group is more than 20 years old.  Hence, there is
> no way to unblock the group.
> 
> This is a serious problem, since the entire collection of postings going
> back many years has been blocked, no just the spam.  This resource is
> frequently used by IDL programmers.
> 
> Seeing the spam postings in this newsgroup, I expect something similar
> may happen to comp.lang.python, soon.

simple solution stop using google groups & use either the mailing list or 
a news server with an NNTP client



-- 
Your wig steers the gig.
-- Lord Buckley
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help to debug my free library

2018-01-31 Thread alister via Python-list
On Thu, 01 Feb 2018 06:48:03 +1100, Chris Angelico wrote:

> On Thu, Feb 1, 2018 at 6:41 AM, Victor Porton  wrote:
>> wxjmfa...@gmail.com wrote:
>>
>>> Le mercredi 31 janvier 2018 20:13:06 UTC+1, Chris Angelico a écrit :
 On Thu, Feb 1, 2018 at 5:58 AM, Victor Porton 
 wrote:
 > LibComCom is a C library which passes a string as stdin of an OS
 > command and stores its stdout in another string.

 Something like the built-in subprocess module does?

 ChrisA
>>>
>>> Do you mean the buggy subprocess module (coding of characters) ?
>>
>> Please elaborate: which bugs it has? in which versions?
>>
>>> Yes, there is a working workaround : QtCore.QProcess().
> 
> Ignore jmf, he wouldn't know a bug if he were eating it for dinner. His
> posts are blocked on the mailing list, and you'd do well to just plonk
> him in your newsreader.
> 
> ChrisA


I disagree jmf's posts are worth reading, if you find yourself agreeing 
with him you know you have got something wrong.


-- 
Bernard Shaw is an excellent man; he has not an enemy in the world, and
none of his friends like him either.
-- Oscar Wilde
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-31 Thread alister via Python-list
On Tue, 30 Jan 2018 21:22:39 +0100, Jugurtha Hadjar wrote:

> On 01/29/2018 03:48 PM, alister via Python-list wrote:
>> On Mon, 29 Jan 2018 15:20:06 +0100, Jugurtha Hadjar wrote:
>>
>>> On 01/28/2018 04:43 PM, Skip Montanaro wrote:
>>>> I've never been a Windows user, but at my current job, Windows is
>>>> core to just about everything, so I am forced to use it for a lot of
>>>> stuff (Outlook, SQL Server, Excel, etc).
>>> I was hired at a startup which made a good impression on me and I was
>>> eager to start working. I checked in for my first day, signed the
>>> paperwork, then the CTO showed me around and told me "Here's your
>>> laptop, you can install Windows and I'll check in with you later".
>>> Life started draining out of my body and my mind was racing in all
>>> directions before he even finished his sentence. I felt tricked: I was
>>> hired based on a test and the file I've received was a *.tar.gz* and
>>> it made me happy because I assumed they were a NIX shop..
>>>
>>> I was considering how I should go about quitting gracefully. I have
>>> stopped using Windows in 2008 for psychological reasons for it made me
>>> really anxious, irritable, angry, and tense to the point of abusing
>>> hardware with low kicks and punches which was not very healthy or
>>> sane. It was only when I switched OS that this behavior stopped. There
>>> was no way I would be going back to my bully.
>>>
>>> The CTO then said "Sorry.. I meant Ubuntu." and seeing my pale face,
>>> he said in a reassuring tone "Don't be afraid, there are no Windows
>>> machines here." which brought me back to life.
>>>
>>> I hope to be as brave as you some day.
>> Any Vacancies whatever they do I am sure I can learn :-)
>>
>>
>>
>>
> We're hiring all the good (technical and human side) people we can
> find/afford. It's a small startup that helps its clients improve
> business using machine learning. We're in Algiers, Algeria and Paris,
> France.

bit of a commute from Sevenage in UK



-- 
A pencil with no point needs no eraser.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread alister via Python-list
On Tue, 30 Jan 2018 07:28:58 +, Steven D'Aprano wrote:

> On Mon, 29 Jan 2018 21:32:11 -0800, Rustom Mody wrote:
> 
>> On Sunday, January 28, 2018 at 8:37:11 PM UTC+5:30, Steven D'Aprano
>> wrote:
>>> I'm seeing this annoying practice more and more often. Even for
>>> trivial pieces of text, a few lines, people post screenshots instead
>>> of copying the code.
>>> 
>>> Where has this meme come from? It seems to be one which inconveniences
>>> *everyone* involved:
>> 
>> Have you heard of the “Dutch Reach¨?
>> http://www.telegraph.co.uk/travel/news/the-dutch-reach-how-opening-car-
> door-like-the-dutch-could-save-lives-cycling/
> 
> Ah, yes, the Dutch Reach. That would be like the French Pox (which isn't
> French), the Spanish Flu (that didn't start in Spain), the Jerusalem
> artichoke (which is neither an artichoke nor from Jerusalem), and the
> turkey (the bird, which has nothing to do with Turkey, the country).
> 
> This technique is neither taught nor commonly used used by the Dutch:
> apparently some Americans decided that because the Netherlands has a lot
> of cyclists, they'll say its Dutch.
> 
The British TV show QI seemed to think this is actually part of the Dutch 
driving test although they have been known to make mistakes

> https://en.wikipedia.org/wiki/Dooring
> 
> So let me see if I understand the logic...
> 
> Rather than teach people to *explicitly* check their mirror to make sure
> it is safe before opening the car door, teach them a difficult, awkward
> maneuver which they're guaranteed to stop using the second the driving
> test is over, that merely points their head more-or-less vaguely in the
> right direction to *maybe* notice on-coming cyclists *if and only if*
> they're actually paying attention.
> 
> I can see this falls under the problem solving technique, "We must do
> something, this is something, therefore we must do it!"
> 
on this I can agree with you.
Personally I tend to "crack" the door a little & then look down the road 
Before opening fully. i am pretty sure I also (at least subconsciously) 
check the mirror.
Then again many* cyclists tend to be in the blind spot, dressed in dark 
clothing & have no lights & ride with zero regard to the rules of the 
road.

> The sorts of people who can't remember to check their mirror before
> opening the car door aren't the sort who will remember to use this
> awkward technique. And for those who can remember to do so, it is
> simpler and more effective to explicitly check your mirror (as the Dutch
> actually do).
> 
> 
>> Presumably it goes beyond the 'inconvenience' of images-instead-of-text
>> to the saving-of-lives…
> 
> I have no idea what connection you think is between this and emailing
> pictures of source code in place of source code.

* not all, some do appear have a desire to live.



-- 
The pollution's at that awkward stage.  Too thick to navigate and too
thin to cultivate.
-- Doug Sneyd
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Mon, 29 Jan 2018 12:17:39 +1300, Gregory Ewing wrote:

> Steven D'Aprano wrote:
>> (The day a programmer posts a WAV file of themselves reading their code
>> out aloud, is the day I turn my modem off and leave the internet
>> forever.)
> 
> Shh! Don't give them ideas!

just wait, once they realise you cant send pictures to a text only news 
group they take the screen shot, print it place it on a wooden table*, 
photograph it & then convert the JPeg to base64 encoding so they can 
paste it in!


* credit to thedailywtf.com


-- 
You look tired.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Mon, 29 Jan 2018 15:20:06 +0100, Jugurtha Hadjar wrote:

> On 01/28/2018 04:43 PM, Skip Montanaro wrote:
>> I've never been a Windows user, but at my current job, Windows is core
>> to just about everything, so I am forced to use it for a lot of stuff
>> (Outlook, SQL Server, Excel, etc).
> 
> I was hired at a startup which made a good impression on me and I was
> eager to start working. I checked in for my first day, signed the
> paperwork, then the CTO showed me around and told me "Here's your
> laptop, you can install Windows and I'll check in with you later". Life
> started draining out of my body and my mind was racing in all directions
> before he even finished his sentence. I felt tricked: I was hired based
> on a test and the file I've received was a *.tar.gz* and it made me
> happy because I assumed they were a NIX shop..
> 
> I was considering how I should go about quitting gracefully. I have
> stopped using Windows in 2008 for psychological reasons for it made me
> really anxious, irritable, angry, and tense to the point of abusing
> hardware with low kicks and punches which was not very healthy or sane.
> It was only when I switched OS that this behavior stopped. There was no
> way I would be going back to my bully.
> 
> The CTO then said "Sorry.. I meant Ubuntu." and seeing my pale face, he
> said in a reassuring tone "Don't be afraid, there are no Windows
> machines here." which brought me back to life.
> 
> I hope to be as brave as you some day.

Any Vacancies
whatever they do I am sure I can learn :-)



-- 
The ideas of economists and political philosophers, both when they
are right and when they are wrong, are more powerful than is generally
understood.  Indeed, the world is ruled by little else.
-- John Maynard Keyes
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread alister via Python-list
On Sun, 28 Jan 2018 22:11:12 +, Stefan Ram wrote:

> Tim Delaney  writes:
>>These are support people who are employed by the company I'm contracted
>>to.
>>Doesn't matter how often I try to train them otherwise, this type of
>>thing keeps happening.
> 
>   That might be more a problem of power.

I would simply repeatedly reject the fault report until the user provided 
the information in the requested format




-- 
Work smarter, not harder, and be careful of your speling.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing "kitchen" module

2018-01-22 Thread alister via Python-list
On Mon, 22 Jan 2018 08:19:51 -0800, codydaviestv wrote:

> On Tuesday, 23 January 2018 02:41:04 UTC+10:30, bream...@gmail.com 
> wrote:
>> On Monday, January 22, 2018 at 3:37:44 PM UTC, codyda...@gmail.com
>> wrote:
>> > So here's the situation. I am unfamiliar with Python but need it to
>> > export a wiki, so I have been following this tutorial, using the
>> > latest version of Python 2 on Windows 7:
>> > 
>> > https://github.com/WikiTeam/wikiteam/wiki/
Tutorial#I_have_no_shell_access_to_server
>> > 
>> > I have everything working up to the point where I run it and it tells
>> > me this:
>> > 
>> > "Please install the Kitchen module.
>> > Please install or update the Requests module."
>> > 
>> > One suggestion was that I try "import kitchen", but that gives me
>> > this error:
>> > 
>> > "Traceback :
>> >   File "", line 1, in 
>> > ImportError: No module named kitchen"
>> > 
>> > So I went to https://pypi.python.org/pypi/kitchen/ to download it,
>> > but that hasn't helped. Maybe it needs to be in a specific folder to
>> > work?
>> > 
>> > Any help would be appreciated.
>> > 
>> > P.S. Here is someone else running into the same problem but they
>> > seemed to have fixed it through a solution that didn't work for me
>> > (it doesn't recognise a command called sudo in the first place when I
>> > type it): https://github.com/WikiTeam/wikiteam/issues/252
>> 
>> Forget sudo as that's a *nix command.  From the command line you should
>> be able to run:-
>> 
>> pip install kitchen pip install requests
>> 
>> --
>> Kindest regards.
>> 
>> Mark Lawrence.
> 
> Here's what I see when I try that. Maybe I'm missing some kind of
> initial setup? https://i.imgur.com/XQHO19W.png

run it from the windows command line not the Python prompt



-- 
Scientists will study your brain to learn more about your distant cousin, 
Man.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: : ✨✨ python 2018 wiki - a piece of cake ✨✨ --- 

2018-01-08 Thread alister via Python-list
On Mon, 08 Jan 2018 15:55:00 +, user net wrote:

> Abdur-Rahmaan Janhangeer:
>> there is a language called python by guido
>> 
>> you can ask your questions here !
> 
> 
> 
> ✨✨  python - a piece of cake  ✨✨
> 
> 
> when u read this post in thunderbird or torBrowser, you see colored
> emoji font
> 
> in other newsreaders, like XPN, pan, etc., it is black & white only.
> 
> how to get colored emoji icons  - like the above cake -   everywhere ?

I am using Pan & it is in colour - not that i would loose any sleep if it 
wasn't 





-- 
Wrinkles should merely indicate where smiles have been.
-- Mark Twain
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2017-12-29 Thread alister via Python-list
On Thu, 28 Dec 2017 18:54:31 -0800, breamoreboy wrote:

> On Thursday, December 28, 2017 at 7:40:14 PM UTC, alister wrote:
>> On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:
>> 
>> > How to use goto in python?
>> > 
>> > ---
>> > This email has been checked for viruses by AVG.
>> > http://www.avg.com
>> 
>> Dont!
>> actually you cant - there isn't one*
>> 
>> *at least not in the core language no doubt some sick person will have
>> manager to hack together some sort of dodgy code to simulate it if you
>> look hard enough)
>> 
>> 
> This http://entrian.com/goto/ has been around for almost 14 years.

ok ill admit i didn't look at all (because goto is a silly idea & 
unnecessary)



-- 
The sunlights differ, but there is only one darkness.
-- Ursula K. LeGuin, "The Dispossessed"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Goto

2017-12-28 Thread alister via Python-list
On Thu, 28 Dec 2017 00:58:48 -0200, Duram wrote:

> How to use goto in python?
> 
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com

Dont!
actually you cant - there isn't one*

*at least not in the core language no doubt some sick person will have 
manager to hack together some sort of dodgy code to simulate it if you 
look hard enough)



-- 
Bigmac's brother was reliably believed to be in the job of moving video
recorders around in an informal way.
(Only You Can Save Mankind)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with this regex for matching emails?

2017-12-19 Thread alister via Python-list
On Wed, 20 Dec 2017 08:21:02 +1100, Chris Angelico wrote:

> On Wed, Dec 20, 2017 at 7:21 AM, alister via Python-list
> <python-list@python.org> wrote:
>> On Mon, 18 Dec 2017 07:57:27 +1100, Ben Finney wrote:
>>> A more correct match would boil down to:
>>>
>>> * Match any printable Unicode characters (not just ASCII).
>>>
>>> * Locate the *last* ‘@’ character. (An email address may contain more
>>>   than one ‘@’ character; you should allow any printable ASCII
>>>   character in the local part.)
>>>
>>> * Match the domain part as the text after the last ‘@’ character.
>>> Match
>>>   the local part as anything before that character. Reject an address
>>>   that has either of these empty.
>>>
>>> * Validate the domain by DNS request. Your program is not an authority
>>>   for what domains are valid; the only authority for that is the DNS.
>>>
>>> * Don't validate the local part at all. Your program is not an
>>> authority
>>>   for what local parts are accepted to the destination host; the only
>>>   authority for that is the destination mail host.
>>
>> At which point you have basicaly boiled your test down to
>> @. which is rather pointless
> 
> Not quite. Firstly, I would exclude all whitespace from your matchable
> characters; even though technically you CAN have spaces in email
> addresses, that'll almost never happen, and it's a lot more common to
> delimit with whites. Secondly, there's actually no requirement to have a
> dot in the domain part (and Ben never said so). However, you can
> straight-forwardly validate the domain by attempting a lookup.
> 
> rosuav@sikorsky:~$ dig +short mx ntlworld.com 1
> mx.tb.ukmail.iss.as9143.net.
> 1 mx.mnd.ukmail.iss.as9143.net.
> rosuav@sikorsky:~$ dig +short mx benfinney.id.au 10
> in1-smtp.messagingengine.com.
> 20 in2-smtp.messagingengine.com.
> rosuav@sikorsky:~$ dig +short mx dud.example.off.rosuav.com
> rosuav@sikorsky:~$
> 
> If there are no MX records for a domain, either the domain doesn't
> exist, or it doesn't receive mail. (Remove the "+short" for a more
> verbose report, in which case the failure state is a return code of
> NXDOMAIN.)
> 
>> there are only 2 reasons why you would want an email anyway
>>
>> 1) Data mining, just to add to your mailing list- in which case even if
>> it validates you still don't know if it is a fake address to prevent
>> spam so validating is pointless
>>
>> 2) it is part of a registration process, in which case if it is
>> incorrect the registration email will not be received & registration
>> cannot be completed so self validating without any effort.
> 
> 3) You're building a text display system (forum posts, text chat, etc,
> etc) and want to have web links and email addresses automatically become
> clickable
possible but again if people making the posts want to be contacted & will 
list a working email address, more likely it will be munged to stop the 
spammers from harvesting it. otherwise if an emaikl has to be given they 
will provide a valid looking fake.
> 
> 4) You ask a user to provide "contact information". If s/he provides an
> email address, you automatically send emails; if a phone number, you
> automatically send SMS/text messages; otherwise, you leave it up to a
> human to contact the user.
> 
I can see auto detecting between a Tel no & an email may be a plausible 
desire, you now have 2 problems because not only are email address so 
difficult to validate that it is not worth the effort telephone numbers 
are also to variable to validate reliably (assuming an international 
audience)

> Plenty of possibilities beyond those two. Don't assume there's nothing
> else that can be done just because your imagination can't come up with
> anything :)

Indeed the most obvious other reason is scraping web pages Newsgroups & 
forums for email addresses to spam & I am sure no-one wants to help with 
that

> 
> ChrisA





-- 
I know you believe you understand what you think this fortune says, but
I'm not sure you realize that what you are reading is not what it means.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is wrong with this regex for matching emails?

2017-12-19 Thread alister via Python-list
On Mon, 18 Dec 2017 07:57:27 +1100, Ben Finney wrote:

> Peng Yu  writes:
> 
>> Hi,
>>
>> I would like to extract "a...@efg.hij.xyz". But it only shows ".hij".
> 
> Others have address this question. I'll answer a separate one:
> 
>> Does anybody see what is wrong with it? Thanks.
> 
> One thing that's wrong with it is that it is far too restrictive.
> 
>> email_regex =
>> re.compile('[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)')
> 
> This excludes a great many email addresses that are valid. Please don't
> try to restrict a match for email addresses that will exclude actual
> email addresses.
> 
> For an authoritative guide to matching email addresses, see RFC 3696 §3
> .
> 
> A more correct match would boil down to:
> 
> * Match any printable Unicode characters (not just ASCII).
> 
> * Locate the *last* ‘@’ character. (An email address may contain more
>   than one ‘@’ character; you should allow any printable ASCII character
>   in the local part.)
> 
> * Match the domain part as the text after the last ‘@’ character. Match
>   the local part as anything before that character. Reject an address
>   that has either of these empty.
> 
> * Validate the domain by DNS request. Your program is not an authority
>   for what domains are valid; the only authority for that is the DNS.
> 
> * Don't validate the local part at all. Your program is not an authority
>   for what local parts are accepted to the destination host; the only
>   authority for that is the destination mail host.

At which point you have basicaly boiled your test down to 
@. which is rather pointless

there are only 2 reasons why you would want an email anyway

1) Data mining, just to add to your mailing list- in which case even if 
it validates you still don't know if it is a fake address to prevent spam 
so validating is pointless

2) it is part of a registration process, in which case if it is incorrect 
the registration email will not be received & registration cannot be 
completed so self validating without any effort.




-- 
OMNIVERSAL AWARENESS??  Oh, YEH!!  First you need four GALLONS of JELL-O
and a BIG WRENCH!! ... I think you drop th'WRENCH in the JELL-O as if
it was a FLAVOR, or an INGREDIENT ... ... or ... I ... um ... WHERE'S
the WASHING MACHINES?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-17 Thread alister via Python-list
On Sat, 16 Dec 2017 14:41:00 +1200, Marko Rauhamaa wrote:

> r...@zedat.fu-berlin.de (Stefan Ram):
> 
>> Varun R  writes:
>>>I'm new to programming, can anyone guide me, how to start learning
>>>python programming language
>>
>>   As a start, one should learn:
>>
>> 1.) how to install Python
>> (if not already installed)
>>
>> 2.) how to start the Python console
>> (if not already started)
>>
>> 3.) how to type characters into a line of the
>> console and how to submit the line (using the Enter key) (if
>> this is not already known)
> 
> A good list. Even more important, though, is the installation, use and
> understanding of a text editor. What is the difference of MS Word,
> Notepad and a Python-aware text editor? What text editors are there?
> What is a newline? What is whitespace? (Advanced: what is a TAB.) What
> is the difference between lower case and upper case? What is trailing
> whitespace? What is an underscore?
> What is the difference between a parenthesis, bracket and a brace?
> 
> What is a file? What is a filename? What is a directory/folder? What is
> a pathname? What is a terminal (emulator)? What is standard input? What
> is standard output?
> 
> How do I see the listing of files? How do I erase a file? How do I
> rename a file? What is the current working directory? How do I change it
> and why?
> 
> 
> Marko

you seem to be moving more into knowledge about the operating system 
rather than programming itself.

Still a good pre-requisite you cannot hope to successfully program a 
system you do no know how to use



-- 
Mr Young hadn't had to quiet a screaming baby for years. He'd never been
much good at it to start with. He'd always respected Sir Winston 
Churchill,
and patting small versions of him on the bottom had always seemed
ungracious.
-- (Terry Pratchett & Neil Gaiman, Good Omens)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double

2017-12-15 Thread alister via Python-list
On Fri, 15 Dec 2017 11:48:20 +1300, Gregory Ewing wrote:

> Rhodri James wrote:
>> Even then there was RiscOS, which divorced file names from file types
>> entirely.
> 
> As did classic MacOS.
> 
> I believe MacOSX also has the ability to store a file type as metadata,
> but it doesn't seem to be used much.

Amiga os used a separate file as the ICON & this contained lots of meta 
data including which application to open the file with (usualy the 
application that created it)



-- 
"I'd love to go out with you, but I have to stay home and see if I snore."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double

2017-12-12 Thread alister via Python-list
On Tue, 12 Dec 2017 05:52:41 -0800, Rick Johnson wrote:

> Rustom Mody wrote:
>> This thread is getting like a mini hologram of our current surreal time
>>  If we can put aside who is right and wrong for a moment we see the
>> more frightening spectacle that Repubs and democrats, Remainers and
>> Brexiters and so on all over  by getting more and more shrill are not
>> talking to each other but past each other
> 
> I blame the confirmation bias of social media for the current state of
> dissed-discourse we find ourselves in these days.
> 
>> > [Rick Johnson wrote]
>> > A file with no extension (regardless of the OS or desktop enviroment
>> > that it was created on), is like a sealed box with no label to
>> > indicate the contents.
>> 
>> So to Rick:  Not if you use something like file (magic) My (unschooled)
>> estimate is it gets its detection right 80% of the time
> 
> But this suggestion misses my point entirely. And the point is, we
> shouldn't have to pick-up the "box" (aka: file) and shake it (ook-ook)
> just to "intuit" what is inside. Using file extentions (aka: labels)
> solves this semantical problem much more elegantly. Now, is a perfect
> solution? Of course not! However, it is the most practical solution.
> 
>> And to Chris and others who think file(magic) is a replacement for
>> file-associations. Even assuming that magic works 100% :
>> Say I have an html file.
>> That means its ALSO a text file.
>> So its equally legitimate to set defaults to use:
>> - a plain text editor (of which there are hundreds)
>> - to open it in browser of choice (also plural nowadays)
>> - some sort of html composer - etc
>> 
>> Which means we are beyond the nature of the file per se to the pattern
>> of its usage
> 
> And although an automated "intuitor" could easily determine if a file
> contained a markup language, we would still be force to "shake the box"
> by running it.

Back to the original problem
has the execute bit been set on the file?




-- 
All Hell hadn't been let loose. It was merely Detritus. But from a few 
feet away you couldn't tell the difference.
(The Fifth Elephant)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please tell me how to execute python file in Ubuntu by double click

2017-12-09 Thread alister via Python-list
On Wed, 06 Dec 2017 10:35:58 +1200, Steve D'Aprano wrote:

> On Tue, 5 Dec 2017 07:58 pm, Lawrence Dâ ÖOliveiro wrote:
> 
>> On Tuesday, December 5, 2017 at 3:39:26 AM UTC+13, Rick Johnson wrote:
>>>
>>> Sounds like your OS file associations are all botched-up ...
>>
>> Linux doesnâ Öt do â £OS file associationsâ Ø.
> 
> 
> Then how does my Linux box know that when I double-click on a text file,
> it launches kwrite rather than (say) the Gimp or LibreOffice?
> 
> When I right-click on a mp4 video, I get a menu that includes a Open
> With command that shows (amount others) Kaffeine, mplayer and VLC.
> 
> If you mean the Linux *kernel* doesn't do file associations, then you
> should have said so.
> 
> But why do you care about the kernel? Would you think it even the
> *tiniest* useful to claim that "Linux doesn't do email" because it is
> sendmail or postfix
>  (or similar) that sends email rather than the Linux kernel itself?

Linux does not associate by file extn it uses a 'magic' file to analyse 
the content of the file so that it runs the correct application 
regardless of the file extn.

to get a python program to run it simply needs the correct "Shebang" ass 
the 1st line

Usually 

#!/usr/bin/env python
 
or similar




-- 
Some say the world will end in fire,
Some say in ice.
From what I've tasted of desire
I hold with those who favor fire.
But if it had to perish twice,
I think I know enough of hate
To say that for destruction, ice
Is also great
And would suffice.
-- Robert Frost, "Fire and Ice"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: connect four (game)

2017-11-26 Thread alister via Python-list
On Sat, 25 Nov 2017 12:26:52 -0800, namenobodywants wrote:

> On Friday, November 24, 2017 at 8:07:07 AM UTC-8, Chris Angelico wrote:
> 
>> This is the kind of function that needs a docstring and some comments.
>> What exactly is this doing? What are the "lines" of the board? What's
>> the difference between "linear" and "lines"? What exactly is it
>> returning?
> 
> producing documentation is an extremely difficult task for me, but i've
> come up with the following:
> 
> """
> makelines(length,numrows,numcolumns) IS THE LIST OF ALL LISTS L, WITH
> LENGTH length, OF COORDINATES FROM A numrows x numcolumns MATRIX, SUCH
> THAT THE ENTRIES OF L ALL LIE IN A LINE:
> 
> LET horizontal BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN
> A HORIZONTAL LINE LET vertical BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN A VERTICAL LINE LET downward BE ALL THE
> APPROPRIATE-LENGTH LISTS WHOSE ENTRIES LIE IN A DOWNWARD-SLOPING
> DIAGONAL LINE LET upward BE ALL THE APPROPRIATE-LENGTH LISTS WHOSE
> ENTRIES LIE IN AN UPWARD-SLOPING DIAGONAL LINE THEN
> makelines(length,numrows,numcolumns) IS THE UNION OF ALL THE
> AFOREMENTIONED SETS """
> 
> def makelines(length,numrows,numcolumns):
> horizontal = [[(i, j+k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)]
> vertical = [[(i+k, j) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] downward = [[(i+k, j+k)
> for k in range(length)] for i in range(numrows) for j in
> range(numcolumns)]
> upward = [[(i+k, j-k) for k in range(length)] for i in
> range(numrows) for j in range(numcolumns)] linear = horizontal +
> vertical + downward + upward return [line for line in linear if
> all(i in range(6) and j in range(7) for (i,j) in line)]
> 
> def getlines(board):
> coordlines = makelines(4,6,7) ## GLOBAL return [[board[square] for
> square in line] for line in coordlines
> 
> 
> i tried to remove all the superfluous spaces from that, but lining up
> code vertically is very helpful to me, so i don't think i can really
> dispense with the practice
> 
> peace stm

the documentation should come after the def statement
that way is becomes a "Doc String" & can be accessed using the help 
function
you may also want to check out the recommended way of structuring a doc 
string, it could help you with your difficulty in writing them (a problem 
shared by many)



-- 
This door is baroquen, please wiggle Handel.
(If I wiggle Handel, will it wiggle Bach?)
-- Found on a door in the MSU music building
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pros and cons of Python sources?

2017-11-25 Thread alister via Python-list
On Sat, 25 Nov 2017 09:20:44 +, Martin Schöön wrote:

> Some time ago I was advised that having a Python installation based on
> several sources (pip and Debian's repos in my case) is not a good idea.
> I need to tidy up my installation and I don't know what to opt for and
> what to opt out.
> 
> What are the pros and cons of the alternatives including the ones I
> haven't mentioned? Completeness, currency, bugs...
> 
> /Martin

Personally i would always use the Distro repository first & only use a 
3rd party option (including pip) if the package I required was not 
available
this ensures compatibility with the OS.


-- 
I must get out of these wet clothes and into a dry Martini.
-- Alexander Woolcott
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: for/ if against dict - one liner

2017-11-14 Thread alister via Python-list
On Tue, 14 Nov 2017 00:44:18 -0500, Andrew Z wrote:

> Hello,
>  i wonder how do i get the "for" and "if" to work against a dictionary
>  in
> one line?
> 
> basically i want to "squeeze":
>  dct= [ 1 : "one", 2:"two", 3:"three"]
>  for k, val in dct:
>if k >= 2:
>   # do magnificent things
> 
> Thank you AZ

why the need to single line it?
is your computer running out of new line & space characters?
it probably could be done with a dictionary comprehension but will that 
make things easier or harder to read/understand?

"Readability counts"




-- 
(Presuming for the sake of argument that it's even *possible* to design
better code in Perl than in C.  :-)
-- Larry Wall on core code vs. module code design
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compression of random binary data

2017-10-23 Thread alister via Python-list
On Mon, 23 Oct 2017 13:40:59 +, Neil Cerutti wrote:

> On 2017-10-23, Chris Angelico <ros...@gmail.com> wrote:
>> On Mon, Oct 23, 2017 at 11:18 PM, alister via Python-list
>><python-list@python.org> wrote:
>>> On Mon, 23 Oct 2017 10:41:55 +0100, Paul Moore wrote:
>>>
>>>> On 23 October 2017 at 10:32,  <danceswithnumb...@gmail.com>
>>>> wrote:
>>>>> According to this website. This is an uncompressable stream.
>>>>>
>>>>> https://en.m.wikipedia.org/wiki/Incompressible_string
>>>>>
>>>>> 12344321
>>>>>
>>>>> It only takes seven 8 bit bytes to represent this
>>>>
>>>> Would you care to provide the seven 8-bit bytes you propose to use?
>>>> Paul
>>>
>>> I would suspect he is using BCD & storing 2 values in reach byte that
>>> is not what is meant by you cant compress random data. his compression
>>> is simply removing redundant space from an inefficient coding
>>
>> I suspect he is using ASCII and storing one value in each byte.
> 
> There's also ZSCII, which stores roughly 3 characters every 2 bytes.
> Since all the digits are in A2, this sequence would take up 7 bytes in
> ZSCII as well.
> 
> http://inform-fiction.org/zmachine/standards/z1point0/sect03.html

not sure how 16 characters can be represented by either ascii or zscii in 
only 8 bytes



-- 
I fear explanations explanatory of things explained.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Compression of random binary data

2017-10-23 Thread alister via Python-list
On Mon, 23 Oct 2017 10:41:55 +0100, Paul Moore wrote:

> On 23 October 2017 at 10:32,   wrote:
>> According to this website. This is an uncompressable stream.
>>
>> https://en.m.wikipedia.org/wiki/Incompressible_string
>>
>> 12344321
>>
>> It only takes seven 8 bit bytes to represent this
> 
> Would you care to provide the seven 8-bit bytes you propose to use?
> Paul

I would suspect he is using BCD & storing 2 values in reach byte
that is not what is meant by you cant compress random data.
his compression is simply removing redundant space from an inefficient 
coding

Can you compress that sequence on paper when you only have the values 0-9 
to work with (forget computer representation & removing un-used bits)


-- 
Old age and treachery will overcome youth and skill.
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >