Re: Strange Python related errors for androwarn.py. Please help!

2016-05-27 Thread Michael Torrie
On 05/27/2016 08:09 PM, Michael Torrie wrote:
> On 05/27/2016 08:41 AM, Sean Son wrote:
>> Thank you for your reply. So the error isnt due to a bug in function
>> itself? It is due to a possible error in the Android APK file?  If that
>> is the case, it would take a while to figure this out. I tried contacted
>> the author of the project but I have yet to hear back from him .
> 
> Yes it sounds like a bug, but the bug is probably not in the function
> that you pointed to.  The exception occurs there, yes, but it occurs
> because the function is expecting an integer to be passed to it, but is
> receiving a string instead.  In other words, something is passing bad
> data (or data the function doesn't know how to interpret).  

I guess I don't mean integer.  I mean it expects a string that can be
converted to an integer.  But it's getting some other text instead,
which it doesn't know how to handle.

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


Re: Strange Python related errors for androwarn.py. Please help!

2016-05-27 Thread Michael Torrie
On 05/27/2016 08:41 AM, Sean Son wrote:
> Thank you for your reply. So the error isnt due to a bug in function
> itself? It is due to a possible error in the Android APK file?  If that
> is the case, it would take a while to figure this out. I tried contacted
> the author of the project but I have yet to hear back from him .

Yes it sounds like a bug, but the bug is probably not in the function
that you pointed to.  The exception occurs there, yes, but it occurs
because the function is expecting an integer to be passed to it, but is
receiving a string instead.  In other words, something is passing bad
data (or data the function doesn't know how to interpret).  Debuggers
and Python are not my strong points, but if you could go back through
the stack trace and find out what's calling it, you might be able to
find out where this bad data is coming from.  I doubt it's an error in
the apk.  More likely Google has changed something inside of apks and
the python code hasn't been updated to account for this.  Could be
something in the XML manifest inside the apk.  Just shooting in the dark
there.  Not so helpful, but that's all I know really.

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


Re: Strange Python related errors for androwarn.py. Please help!

2016-05-26 Thread Michael Torrie
On 05/26/2016 05:57 PM, Michael Torrie wrote:
> You could try emailing the author who's email address is listed on the
> project's main github page.  I suspect the project itself is abandoned.

Ahem. That should have been whose. Sigh.

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


Re: Strange Python related errors for androwarn.py. Please help!

2016-05-26 Thread Michael Torrie
On 05/26/2016 11:31 AM, Sean Son wrote:
> Hopefully those help in any troubleshooting steps that you all recommend to
> me!
> 
> Thank you!

You could try emailing the author who's email address is listed on the
project's main github page.  I suspect the project itself is abandoned.

Was this working before and is no longer working?  What brought about
the change? A new version of Android?  A new version of this program?
Seems like this github project is abandoned and, as you have found,
bitrotting as Android moves on and likely causes incompatibilities with
it as time goes on.

Unless the author can advise you, help may be hard to come by.  The
error itself is simple enough.  But what is feeding bad data to this
function (a string instead of a number) is unknown and would take some
effort to get to the bottom of it, especially by any of us who have
never seen this code before, and many of whom haven't ever worked with
Android before.

If this particular program is critical to your employer's business,
consider offering the original author (or folks on this list) some
payment for the fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: JNLP File download and run

2016-05-24 Thread Michael Torrie
On 05/24/2016 12:01 AM, Robert Clove wrote:
> Can u provide the pseudo code for the same

I think you'll be disappointed.  What you want to do is a simple,
three-step affair in pseudocode:

download the jnlp file
launch javaws to run the jnlp file
delete jnlp file

That *is* the pseudo code in its entirety.  What more are you expecting?
 Here's a simple, possibly naive, bash example:

#!/bin/bash
jnlp_file=$(mktemp tmpX.jnlp)
wget -O - "$1" > "$jnlp_file"
xdg-open "$jnlp_file"
rm -f "$jnlp_file"

On windows, python ships with a handy wrapper in the os module:
http://stackoverflow.com/questions/15054434/how-can-i-open-files-in-external-programs-in-python
.  With this is in mind, we could expand the pseudocode slightly to work
on multiple platforms:

jnlp_file = create a temporary filename with .jnlp extension
download jnlp_url and write it to jnlp_file

if on windows:
   os.startfile(jnlp_file)
elif on mac:
   execute "open" with the jnlp_file
elif on linux:
   execute "xdg-open" with the jnlp_file

delete  jnlp_file

Take a look at the urls I've found and you'll see how to use urllib and
also subprocess (or os.startfile) to do what you want to do, including
examples you can adapt.  Should be just a few of lines of actual python
code to start with.

> 
> On Fri, May 20, 2016 at 9:06 PM, Michael Torrie  <mailto:torr...@gmail.com>> wrote:
> 
> On 05/20/2016 01:30 AM, Robert Clove wrote:
> > Hi,
> >
> > Can someone give me pseudo code to download and JNLP file from a URL and
> > run it?
> >
> > Looks like a advance concept in python
> 
> You could use the urllib module to download the file, then use the
> subprocess module to spawn the javaws executable and pass it the
> location of the jnlp file as a parameter.
> 
> https://docs.python.org/3.6/howto/urllib2.html
> https://docs.python.org/3.6/library/subprocess.html
> 
> There are other ways besides launching javaws directly, such as asking
> cmd.exe to invoke "start" and the jnlp file so that the default javaws
> executable will run. On Mac there's the "open" binary that can do the
> same thing, and on Linux, xdg-open.
> 
> --
> https://mail.python.org/mailman/listinfo/python-list
> 
> 

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


Re: Image loading problem

2016-05-22 Thread Michael Torrie
On 05/21/2016 01:55 PM, Random832 wrote:
> On Sat, May 21, 2016, at 12:54, Peter Otten wrote:
>> It's not your fault, there's an odd quirk in the library: you have to
>> keep a reference of the PhotoImage instance around to prevent the
>> image from being garbage-collected.
> 
> Just out of curiosity, why is this a "quirk" and not a bug? Why isn't
> the reference held by the Label?

The reference is indeed held by the label but the problem is the label
is a Tcl/Tk object, thinly wrapped in Python.  It's essentially an
impedance mismatch between two different languages and object models
that each do their own reference holding and counting. I've run into
this issue with PySide also as one is instantiating C++ objects that do
their own internal reference counting through the Python wrapper.

I'm sure Python wrappers could try to correct for this somewhat, but
it's not a trivial thing to solve by any means.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: JNLP File download and run

2016-05-20 Thread Michael Torrie
On 05/20/2016 01:30 AM, Robert Clove wrote:
> Hi,
> 
> Can someone give me pseudo code to download and JNLP file from a URL and
> run it?
> 
> Looks like a advance concept in python

You could use the urllib module to download the file, then use the
subprocess module to spawn the javaws executable and pass it the
location of the jnlp file as a parameter.

https://docs.python.org/3.6/howto/urllib2.html
https://docs.python.org/3.6/library/subprocess.html

There are other ways besides launching javaws directly, such as asking
cmd.exe to invoke "start" and the jnlp file so that the default javaws
executable will run. On Mac there's the "open" binary that can do the
same thing, and on Linux, xdg-open.

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


Re: Quote of the day

2016-05-17 Thread Michael Torrie
On 05/17/2016 08:27 AM, Paul Rudin wrote:
> Marko Rauhamaa  writes:
>> That's a long time to be without a product to sell.
> 
> But you do have the option of building a kernel incorporating your fix
> and using that.

Sure as an individual end user that may be the best option. But not
necessarily for a business.  The cost of doing that could be
prohibitive.  Sometimes we forget just how costly open source software
can be (really *all* software).  They can either deal with lost revenue
waiting, or they can budget a tremendous amount of money, time, and
effort to support their own kernel which would entail doing updates, QA
testing, etc.  Letting the upstream vendor do all that (their core
business after all) is often the least costly option.  Though it sounds
like they've already spent a lot of money doing QA to identify this bug.

When I did IT professionally, our policy with regards to Linux was to
stick with existing packages from a known set of (mostly) official
channels and to discourage any installing of libraries and frameworks
from source.  Allowing packages to be installed from source was just a
maintenance nightmare.  RPM (or deb or whatever) brings at least a tiny
bit of stability and consistency.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fw: Question about issue with opening Python

2016-05-13 Thread Michael Torrie
On 05/13/2016 07:47 AM, christopher.amor...@mail.citytech.cuny.edu wrote:
> Hello,
> 
> Thank you for your reply. It says "IDLE's subprocess didn't make
> connection. Either IDLE can't start a subprocess or personal firewall
> software is blocking the connection." It worked after the first hour
> or so after downloading the program but now when I open it I keep
> getting this message. I've tried to turn off the firewall as well but
> still get this error message.

Have you tried googling for this error message? I did just now and one
of the top search results including several suggestions, including
making sure you haven't created python scripts and saved them in the
same directory as the python executable or IDLE itself.  If you do that,
and you happen to name your python program the same name as a built-in
module, it will prevent IDLE from loading.  If you have been saving any
python programs in the same directory as Python or IDLE, move them
somewhere else.

Just a shot in the dark. could be way off base.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fw: Question about issue with opening Python

2016-05-13 Thread Michael Torrie
On 05/13/2016 07:05 AM, christopher.amor...@mail.citytech.cuny.edu wrote:
> I downloaded an older version of Python and for about an hour it was
> working, but started to get the same error message I received when
> using the latest version of Python.

You'll have to tells us what the error was that you are seeing.
Attachments are not allowed on this list, so you'll have to type it, or
if you can, copy and paste the exact error.

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


Re: Average calculation Program *need help*

2016-05-12 Thread Michael Torrie
On 05/12/2016 11:03 PM, Jake Kobs wrote:
> Im not sure how to move it inside the for loop. I've been working on
> this small problem for like 4 hours lol.

I'm sorry it's so frustrating.  Sounds like you haven't got down some of
the most basic fundamentals yet.  In Python, things that should happen
one after another are placed at the same indent level on the screen.

For example:

if something:
do_this()
then_this()
then_that()

Everything indented in from the start of the if statement is in a block
and only happens if the if statement condition is true.  If there're
statements at the same level as the if, then they happen *after* the if
and it's block.  In other words, indentation is what tells Python where
you want things to run.  If you want to move the while loop inside the
for loop, you have to adjust it's indentation accordingly (and the
indentation in it's own block).

This is a big gotcha for people unfamiliar with programming in Python,
and unfamiliar with programming in general.  In other languages, indents
don't have to be a certain way, as long as you have the write statements
to close off the loop.  However, Python's method forces you to think
like a programmer and to lay things out on the screen in a logical
fashion, like a writer's outline.

If you're still stuck, you will probably want to sit down with your
teacher and have him or her go over this with you.  This is important
basic stuff you need to have clear in your mind to program computers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Average calculation Program *need help*

2016-05-12 Thread Michael Torrie
On 05/12/2016 10:22 PM, Jake Kobs wrote:
> On Thursday, May 12, 2016 at 10:48:08 AM UTC-5, Jake Kobs wrote:
>> Hello all, I have been struggling with this code for 3 hours now and I'm 
>> still stumped. My problem is that when I run the following code:
>> --
>> #this function will get the total scores
>> def getScores(totalScores, number):
>> for counter in range(0, number):
>> score = input('Enter their score: ')
>> totalScores = totalScores + score
>> 
>> while not (score >= 0 and score <= 100):
>> 
>> print "Your score must be between 0 and 100."
>> score = input('Enter their score: ')
>> 
>> 
>> 
>> return totalScores
>> --
>> the program is supposed to find the average of two test scores and if one of 
>> the scores is out of the score range (0-100), an error message is displayed. 
>> The main problem with this is that when someone types in a number outside of 
>> the range, it'll ask them to enter two scores again, but ends up adding all 
>> of the scores together (including the invalid ones) and dividing by how many 
>> there are. Please help.
>  
> I still can't get it. Someone please tell me lol. I have done everything I 
> can and still I get bad answers.

Tell us what you've done, precisely.  We're here to help you learn, not
give you the answers.

One thing that strikes me is that your while loop doesn't appear to be
indented properly.  You have it running after all the scores have been
inputted in the for loop, but I suspect this isn't what you want.  You
want the while loop to occur each time through the for loop.  Do you
know how to move this while loop to be inside the for loop?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-12 Thread Michael Torrie
On 05/12/2016 03:12 AM, alister wrote:
> On Tue, 10 May 2016 19:40:02 -0400, DFS wrote:
> 
>> Sometimes I try to be a funny smart-aleck and it doesn't work.
> 
> this is the problem everyone is having with your post, you acknowledge 
> that it doesn't work so why keep trying.
> 
> I too can fall guilty of this behavior (I can be a bit condescending of 
> one of our engineers calls for help & asks a question he should already 
> know)  but have learnt that when I am asking for help it is probably not 
> a good idea to upset the person I am asking.

>> Maybe.  I'll always call a spade a spade.

It's really sad to see folks like DFS hop on the list with apparent
enthusiasm for Python and an excitement to learn, only to resort to name
calling and walk away in a huff when folks ask them not to speak that
way around here.  I'm not sure why this is.  I recall that the same
thing happened not so long ago with another poster I recall.  Overall I
think list members are pretty patient with newbies.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python PygLatin

2016-05-09 Thread Michael Torrie
On 05/08/2016 04:21 AM, Cai Gengyang wrote:
> This is a long
> road ahead, but I believe it is worth it because the power of a new
> technology does eventually translate into money. 

If this is your prime motivation, I think you'll be very disappointed.
A good programmer certainly can make a good salary.  But the road to
riches? Well that's actually relatively rare. Just look at the the Apple
Store or Google Play Store.  Thousands of games and apps and very few
small developers making the big dollars through it.  Some manage to get
lucky but most do not.

Really good programmers do it because they enjoy doing it, whether it's
the problem solving aspects, or maybe because they enjoy creating a
product that is useful to others.  While computer programming is a
learned skill, some have more aptitude and intuition for it than others.
 If you honestly enjoy it then you'll do fine.  If you don't find it
intellectually stimulating then you'll definitely struggle as far as a
career path goes.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: After a year using Node.js, the prodigal son returns

2016-05-05 Thread Michael Torrie
On 05/04/2016 02:59 AM, Steven D'Aprano wrote:
> A year ago, Gavin Vickery decided to move away from Python and give 
> Javascript with Node.js a try. Twelve months later, he has written about his 
> experiences:
> 
> 
> http://geekforbrains.com/post/after-a-year-of-nodejs-in-production

Very interesting.  Frankly Javascript sounds awful.  Even on the front end.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fastest way to retrieve and write html contents to file

2016-05-02 Thread Michael Torrie
On 05/02/2016 01:37 AM, DFS wrote:
> So python matches or beats VBScript at this much larger file.  Kewl.

If you download something large enough to be meaningful, you'll find the
runtime speeds should all converge to something showing your internet
connection speed.  Try downloading a 4 GB file, for example.  You're
trying to benchmark an io-bound operation.  After you move past the very
small and meaningless examples that simply benchmark the overhead of the
connection building, you'll find that all languages, even compiled
languages like C, should run at the same speed on average.  Neither VBS
nor Python will be faster than each other.

Now if you want to talk about processing the data once you have it,
there we can talk about speeds and optimization.

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


Re: Need help understanding list structure

2016-05-02 Thread Michael Torrie
On 05/02/2016 04:33 PM, moa47...@gmail.com wrote:
> Yes, that does help. You're right. The author of the library I'm
> using didn't implement either a __str__ or __repr__ method. Am I
> correct in assuming that parsing a large text file would be quicker
> returning pointers instead of strings? I've never run into this
> before.

I'm not sure what you mean by "returning pointers." The list isn't
returning pointers. It's a list of *objects*.  To be specific, a list of
gedcom.Element objects, though they could be anything, including numbers
or strings.  If you refer to the source code where the Element class is
defined you can see what these objects contain. I suspect they contain a
lot more information than simply text.

Lists of objects is a common idiom in Python.  As you've discovered, if
you shallow copy a list, the new list will contain the exact same
objects.  In many cases, this does not matter.  For example a list of
numbers, which are immutable or unchangeable objects.  It doesn't matter
that the instances are shared, since the instances themselves will never
change.  If the objects are mutable, as they are in your case, a shallow
copy may not always be what you want.

As to your question.  A list never shows "pointers" as you say.  A list
always contains objects, and if you simply "print" the list, it will try
to show a representation of the list, using the objects' repr dunder
methods.  Some classes I have used have their repr methods print out
what the constructor would look like, if you were to construct the
object yourself.  This is very useful.  If I recall, this is what
BeautifulSoup objects do, which is incredibly useful.

In your case, as Erik said, the objects you are dealing with don't
provide repr dunder methods, so Python just lets you know they are
objects of a certain class, and what their ids are, which is helpful if
you're trying to determine if two objects are the same object.  These
are not "pointers" in the sense you're talking.  You'll get text if the
object prints text for you. This is true of any object you might store
in the list.

I hope this helps a bit.  Exploring from the interactive prompt as you
are doing is very useful, once you understand what it's saying to you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 10:06 PM, Christopher Reimer wrote:
> On 4/27/2016 8:52 PM, Michael Torrie wrote:
>>   In fact if it were me I would save game state to some kind of ini file,
>> which would mean manually going through each object and writing out the
>> relevant data to the ini file using the right syntax. And then reverse
>> the process when restoring from a file.  XML could be another format
>> used for your file, if you're into that kind of thing.
> 
> Funny that you should mention the ini file. I wrote a ConfigParser class 
> for my const['whatever'] variable. It wouldn't take much to use that in 
> the meantime until I get a handle on pickle.

I'm not sure pickle is the way to go anyway.  Especially for your
purposes. Definitely you could make a ConfigParser that could read and
write your object instances.

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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 08:49 PM, Christopher Reimer wrote:
> On 4/27/2016 7:00 PM, Michael Torrie wrote:
>> I am guessing that the reason you are storing state as it's own 
>> dictionary is so that you can pass the state itself to the constructor? 
> 
> Someone said it was bad to store the object itself to file (my original 
> plan) and that I should use a dictionary instead. This is my 
> implementation of that idea. However, saving and loading data is far 
> down my to do list.

Pickle should be able to serialize an object that stores state as
attributes, as that's what objects normally do.

But you could also serialize and save the objects yourself manually too.
 In fact if it were me I would save game state to some kind of ini file,
which would mean manually going through each object and writing out the
relevant data to the ini file using the right syntax. And then reverse
the process when restoring from a file.  XML could be another format
used for your file, if you're into that kind of thing.


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


Re: Differences between Class(Object) and Class(Dict) for dictionary usage?

2016-04-27 Thread Michael Torrie
On 04/27/2016 07:12 PM, Christopher Reimer wrote:
> class Piece(object):
>  def __init__(self, color, position, state=None):
>  if state is None:
>  self._state = {
>  'class': self.__class__.__name__,
>  'color': color,
>  'first_move': True,
>  'initial_position': position,
>  'move_count': 0,
>  'name': color.title() + ' ' + self.__class__.__name__,
>  'notation': color.title()[:1] + 
> self.__class__.__name__[:1],
>  'position': position
>  }

I am guessing that the reason you are storing state as it's own
dictionary is so that you can pass the state itself to the constructor?

>  else:
>  self._state = state

I'm not sure why you are storing the class name in self._state above,
but keep in mind that this part of the constructor will just reference
whatever was in the passed-in state object, whether it's right or wrong.
 So the value of self._state.class and self._state.notation may or may
not be right, compared to what is set in the previous section if None is
passed in.  Also self._state = state means that the state object passed
will be the self._state object.  Not a copy, but the exact same object.
 So multiple instances could have the exact object as self._state.  Not
sure if this is what you intended or not.

Personally I would ditch the self._state dictionary entirely and store
the state directly as instance attributes.  self.color, self.first_move,
etc.  For the constructor if you want to duplicate another object's
state, just pass the entire object as an argument and copy the
attributes manually, rather than passing around the state dict.

I know you've stated reasons for doing things the way you have, but this
self._state dict smells a bit funny, especially where you have
self._state = state, which means that several instances could have the
exact same state object at the same time and strikes me as mildly
un-pythonic and very confusing.  "State" is what instances themselves
are supposed to track by design.  I recommend you use this feature
rather than duplicating it with your own error-prone dict handling.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scraping email to make invoice

2016-04-25 Thread Michael Torrie
On 04/25/2016 08:39 AM, Grant Edwards wrote:
> Your normal gmail password is used for IMAP.

Actually, no, unless you explicitly tell Google to allow "less-secure"
authentication.  Otherwise you are required to set up a special,
application-specific password.

https://support.google.com/accounts/answer/185833?hl=en

> Warning: don't use the basic imaplib.  IMAP is a miserable protocol,
> and imap lib is too thin a wrapper. It'll make you bleed from the ears
> and wish you were dead.  Use imapclient or imaplib2.  I've used both
> (with Gmail's IMAP server), and IMO both are pretty good.  Either one
> is miles ahead of plain imaplib.


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


Re: what is the difference between one-line-operation and 2-line-operation

2016-04-25 Thread Michael Torrie
On 04/25/2016 08:13 AM, oyster wrote:
> so, what produces this difference between py2 and py3 in nature? is
> there more examples? where can I find the text abiut his difference?

One thing I see is that both your py2 and py3 examples are treating
print as a function.  It's only a function in Py3. By default in Py2
it's a statement.  You passed it a tuple, and that's what it prints.  If
you add:

from __future__ import print_function

then py2 and py3 will behave the same in regards to print.

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


Re: Scraping email to make invoice

2016-04-24 Thread Michael Torrie
On 04/24/2016 12:58 PM, CM wrote:
> 1. INPUT: What's the best way to scrape an email like this? The
> email is to a Gmail account, and the content shows up in the email as
> a series of basically 6x7 tables (HTML?), one table per PO
> number/task. I know if the freelancer were to copy and paste the
> whole set of tables into a text file and save it as plain text,
> Python could easily scrape that file, but I'd much prefer to save the
> user those steps. Is there a relatively easy way to go from the Gmail
> email to generating the invoice directly? (I know there is, but
> wasn't sure what is state of the art these days).

I would configure Gmail to allow IMAP access (you'll have to set up a
special password for this most likely), and then use an imap library
from Python to directly find the relevant messages and access the email
message body.  If the body is HTML-formatted (sounds like it is) I would
use either BeautifulSoup or lxml to parse it and get out the relevant
information.

> 2. OUPUT: The invoice will have boilerplate content on top and then 
> an Excel table at bottom that is mostly the same information from
> the source content. Ideally, so that the invoice looks good, the
> invoice should be a Word document. For the first pass at this, it
> looked best by laying out the entire invoice in Excel and then copy
> and pasting it into a Word doc as an image (since otherwise the
> columns ran over for some reason). In any case, the goal is to create
> a single page invoice that looks like a clean, professional looking
> invoice.

There are several libraries for creating Excel and Word files,
especially the XML-based formats, though I have little experience with
them.  There are also nice libraries for emitting PDF if that would work
better.

> 3. UI: I am comfortable with making GUI apps, so could use this as 
> the interface for the (somewhat computer-uncomfortable) user. But
> the less user actions necessary, the better. The emails always come
> from the same sender, and always have the same boilerplate language 
> ("Below please find your Purchase Order (PO)"), so I'm envisioning a 
> small GUI window with a single button that says "MAKE NEWEST
> INVOICE" and the user presses it and it automatically searches the
> user's email for PO # emails and creates the newest invoice. I'm
> guessing I could keep a sqlite database or flat file on the computer
> to just track what is meant by "newest", and then the output would
> have the date created in the file, so the user can be sure what has
> been invoiced.

Once you have a working script, your GUI interface would be pretty easy.
 Though it seems to me that it would be unnecessary.  This process
sounds like it should just run automatically from a cron job or something.

> I'm hoping I can write this in a couple of days.

The automated part should be possible, but personally I'd give myself a
week.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Torrie
On 04/23/2016 09:41 PM, Christopher Reimer wrote:
> I never wanted to learn Java in the first place. My community college 
> couldn't afford to renew the Microsoft site license, which local 
> employers required to learn C/C++ in MS Visual Studio, and all flavors 
> of Java got taught for the programming classes instead. I wanted to 
> learn C/C++. I even wanted to learn assembly language, but I was the 
> only student who showed up for the class and it got cancelled.
> 
> Of course, it probably doesn't help that I got a job in help desk 
> support after I graduated with A.S. degree in Java and never programmed 
> professionally. Thinking like a programmer helped me resolved many IT 
> problems over the last 12 years. My current job in computer security 
> requires tinkering with PowerShell scripts as Python is strictly 
> prohibited in this Windows shop. I have made Python my main programming 
> language at home.

I don't mean to imply that I'm criticizing you for your Java experience!
 I am critical of Java, though.

I'm very glad you've discovered Python and I hope you'll continue to
have fun with it.  I hope you'll take the advice offered by the others
on this thread in stride and hopefully we'll all learn and benefit.

I completely agree with you that learning to think like a programmer is
so helpful in solving all kinds of problems, especially in IT!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Torrie
On 04/23/2016 08:32 PM, Christopher Reimer wrote:
> That's the other problem I'm running into. Building a chess engine is a 
> big project. This is probably bigger than the Java XML parser I built 
> from scratch for a college project. I can't seem to find any information 
> on how to build bigger programs. Community college taught me how to 
> program, but it didn't teach me how to go beyond class inheritance.

The reason you weren't taught beyond class inheritance is because Java
implements organization only through a class hierarchy. Whole
generations of Java programmers think that program organization is
through classes (a static main method means your code is procedural, by
the way).

Learn about Python namespaces and how to use them.  I guess it just
comes with experience, a lot of trial and a lot of error.  And checking
on how others are doing it.  Take a look at examples from the Python
standard library, as well as other projects.  For example, Beautiful
Soup.  Not that you have to understand their code, but take a look at
how they organize things.

In my mind namespaces matter more than files as an organizational tool.
 Because namespaces are my primary organization, I will put multiple
class definitions in the same file (if they belong in the same
namespace), so they can be imported from the same module. If the classes
and functions get more complicated, I can separate them into their own
submodules and wrap them all up in one Python package (like a module but
more flexible and has submodules).

The nice thing about building with Python is you can start with one
thing, like a module, and convert it to a package later on as needed.


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


Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Michael Torrie
On 04/23/2016 07:45 PM, Christopher Reimer wrote:
> I had to confront all the bad habits I brought over Java and change my 
> code to be more Pythonic. This is where I started having fun, learning 
> the tricks and collapsing multi-line code into a single line code. I've 
> learned more about Python in the few weeks than I had in two years of 
> writing procedural scripts and translating BASIC goto hell.

Procedural programming does not necessarily mean BASIC-style goto hell.
Not sure why you would think that.  In fact that's not really what
procedural programming is about.  However, Mr. Selik wasn't advocating
procedural programming at all.  Not defining a class does not make your
code precdural.  But using classes does not mean your code is *not*
procedural. If you are using an event-driven framework then I will say,
yes your code is not procedural.

There are many aspects to Pythonic programming, not just OOP.  For
example using modules to store shared state for your program components
is very pythonic, rather than using classes.  A module is kind of like a
singleton instance, and still is object-oriented by the way (the module
is an object).  Sadly Java really messed up people by using classes as a
namespace mechanism.  That was quite a mistake.  Really messed with
people's expectations of OOP.

I would say that pythonic programming involves defining classes when
it's appropriate, and not doing so when something else will work just as
well and be simpler.

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


Re: QWERTY was not designed to intentionally slow typists down

2016-04-17 Thread Michael Torrie
On 04/17/2016 07:39 PM, Steven D'Aprano wrote:
> Even though QWERTY wasn't designed with touch-typing in mind, it's
> interesting to look at some of the weaknesses of the system. It is almost
> as if it had been designed to make touch-typing as inefficient as
> possible :-) Just consider the home keys. The home keys require the least
> amount of finger or hand movement, and are therefore the fastest to reach.
> With QWERTY, the eight home keys only cover a fraction over a quarter of
> all key presses: ASDF JKL; have frequencies of
> 
> 8.12% 6.28% 4.32% 2.30% 0.10% 0.69% 3.98% and effectively 0%
> 
> making a total of 25.79%. If you also include G and H as "virtual
> home-keys", that rises to 33.74%.
> 
> But that's far less than the obvious tactic of using the most common
> letters ETAOIN as the home keys, which would cover 51.18% just from those
> eight keys alone. The 19th century Blickensderfer typewriter used a similar
> layout, with the ten home keys DHIATENSOR as the home keys. This would
> allow the typist to make just under 74% of all alphabetical key presses
> without moving the hands.

While they Dvorak layout also puts more coverage in the home row, and
also lets the touch typist alternate more equally between the fingers, I
had to quit using it because it just wasn't as comfortable to use with
vi, especially for things like cursor navigation, and I didn't really
want to remap all the keys.  vi is very flexible and I bet there are key
mappings for vi that work better with Dvorak.  Maybe if I try it again
I'll have another look.

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


Re: Guido sees the light: PEP 8 updated

2016-04-17 Thread Michael Torrie
On 04/17/2016 10:13 AM, Dennis Lee Bieber wrote:
> On Sat, 16 Apr 2016 21:59:01 -0400, Random832 
> declaimed the following:
> 
>>
>> I heard Windows 10 is going to finally fix this, anyway.
> 
>   Probably by removing the old CLI window completely and making everyone
> learn PowerShell ISE

Or a Linux ELF bash binary running on the new Linux subsystem for
Windows. :)



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


Re: Fraud

2016-04-16 Thread Michael Torrie
On 04/16/2016 04:21 PM, Erik wrote:
> On 16/04/16 23:02, Joel Goldstick wrote:
>>> On Sun, Apr 17, 2016 at 3:12 AM, Mel Drosis via Python-list
>>>  wrote:

 My phone my accounts my home network have all been affected because of 
 someone using coding from Python and Linux and GitHub and json. I don't 
 even know what this stuff is but how do I get rid of it all. It's ruined 
 my life.
> 
>> I'm curious as to what makes you think all this trouble was caused by
>> python, etc.  Did they leave a note?
> 
> If this is genuine, then I don't want to be dismissive of the plea. 
> However, given that Chris's response is quite enough for a genuine 
> request to find a solution, I'll say that I smell a feint hint of troll 
> ... :)

Reminds me of this classic story from 10 years ago:
http://www.theregister.co.uk/2006/03/24/tuttle_centos/

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


Re: Python garbage collection: not releasing memory to OS!

2016-04-15 Thread Michael Torrie
On 04/15/2016 04:25 AM, cshin...@gmail.com wrote:
> The input was a 4MB file. Even after returning from the 'fileopen'
> function the 4MB memory was not released. I checked htop output while
> the loop was running, the resident memory stays at 14MB. So unless
> the process is stopped the memory stays with it.

I guess the question is, why is this a problem?  If there are no leaks,
then I confess I don't understand what your concern is.  And indeed you
say it's not leaking as it never rises above 14 MB.

Also there are ways of reading a file without allocating huge amounts of
memory.  Why not read it in in chunks, or in lines.  Take advantage of
Python's generator facilities to process your data.

> So if the celery worker is not killed after its task is finished it
> is going to keep the memory for itself. I know I can use
> **max_tasks_per_child** config value to kill the process and spawn a
> new one. **Is there any other way to return the memory to OS from a
> python process?.**

Have you tried using the subprocess module of python? If I understand it
correctly, this would allow you to run python code as a subprocess
(completely separate process), which would be completely reaped by the
OS when it's finished.

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


Re: From email addresses sometimes strange on this list - was Re: [beginner] What's wrong?

2016-04-04 Thread Michael Torrie
On 04/04/2016 04:58 PM, Chris Angelico wrote:
> O That probably explains it. It's because of Yahoo and mailing
> lists. Yahoo did stuff that breaks stuff, so Mailman breaks stuff
> differently to make sure that only Yahoo people get messed up a bit.
> It means their names and addresses get slightly obscured, but delivery
> works.

That explains it! The other folks with messages like that are coming
from Yahoo as well.  I can live with it.

Thank you!
-- 
https://mail.python.org/mailman/listinfo/python-list


From email addresses sometimes strange on this list - was Re: [beginner] What's wrong?

2016-04-04 Thread Michael Torrie
On 04/04/2016 08:04 AM, Mark Lawrence via Python-list wrote:
> On 02/04/2016 23:49, Michael Torrie wrote:
>> Mark, your messages are showing up to the list as being from "python,"
>> at least on my email.  Any reason for this?
>>
> 
> Assuming that you're referring to me, frankly I haven't a clue.  I read 
> this list with Thunderbird on Windows, I hit "reply" to something, I 
> type, I hit "send", job done.  Thereafter, as far as I'm concerned, a 
> miracle occurs and hundreds if not thousands of subscribers get to see 
> my reply.

Interesting.  The problem is definitely not on your end at all, though I
first noticed this with your recent posts. Other posts are showing up a
bit weirdly too.  The problem appears to be partly in my Thunderbird
client, and partly the mailing list gateway.  And maybe Gmail is
screwing things up too. Usenet-orginating posts look fine.  For example:

From: Marko Rauhamaa 
Newsgroups: comp.lang.python

Whereas email ones are sometimes looking like this:

From: Mark Lawrence via Python-list 
Reply-To: Mark Lawrence 

Thunderbird on my machine is only seeing the From email address
(python-list@python.org) and I must have that in my address list
somewhere as "python."

What's odder is that my own messages show up as "From:
torr...@gmail.com" and not "via Python-list ".



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


Re: PyQt4

2016-04-03 Thread Michael Torrie
On 04/03/2016 12:57 PM, Muhammad Ali wrote:
> 
> Hi,
> 
> How can we confirm that either  PyQt4 is already installed on LInux machine 
> or not?
> 
> Please suggest commands to confirm the already existence of  PyQt4 in the 
> machine.

Ideally you make a distribution-specific package of the binary in a .deb
on Debian or an RPM on other distros, and specify that it depends on the
package that provides PyQt4.  That way when it's installed, modern
package managers will automatically install the dependencies.

Alternatively you can use try and except in your python code to attempt
to import something from PyQt4 and see if it fails or not.  This
technique is also used to make your code work either PyQt4 or PySide,
depending on which the user has installed.

try:
from PySide import QtGui
except ImportError:
from PyQt4 import QtGui

If neither are installed, this little example will end with an ImportError.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [beginner] What's wrong?

2016-04-02 Thread Michael Torrie
Mark, your messages are showing up to the list as being from "python,"
at least on my email.  Any reason for this?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-28 Thread Michael Torrie
On 03/28/2016 06:44 PM, Steven D'Aprano wrote:
> http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/

I have the same problem as the writer.  Working in Python makes me
really dislike working in any other language!

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


Re: [OT'ish] Is there a list as good as this for Javascript

2016-03-26 Thread Michael Torrie
On 03/26/2016 11:49 AM, Michael Torrie wrote:
> Well said, Ned, and a good reminder for me, and I suspect all of us, to
> considering how we communicate.  It's our nature to think problems lie
^^
Sigh.  Consider.  And proof read.

> with everyone else but us (as witnessed by recent posts from another
> list member in this own thread), and it's good to be reminded to look
> inward as well.


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


Re: [OT'ish] Is there a list as good as this for Javascript

2016-03-26 Thread Michael Torrie
On 03/26/2016 05:37 AM, Ned Batchelder wrote:
> [...]

> Has anyone ever said to you, "Thanks, Thomas! Lots of people were giving
> me answers, but they were all so kind and polite about it, I couldn't
> see what they were saying.  Finally, your blunt direct manner got
> through to me, so now I understand."  Of course not. It's absurd.
> Bluntness doesn't help learning.  It just makes *you* feel good.  
> 
> Points of correctness are useless without points of connection.  You
> have to talk to people in a way that they will hear.  If you can't be
> bothered, then you are just wasting your time, and earning a negative
> reputation for yourself.
> [...]

Well said, Ned, and a good reminder for me, and I suspect all of us, to
considering how we communicate.  It's our nature to think problems lie
with everyone else but us (as witnessed by recent posts from another
list member in this own thread), and it's good to be reminded to look
inward as well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Michael Torrie
On 03/24/2016 04:18 PM, Mark Lawrence wrote:
> On 24/03/2016 19:54, BartC wrote:
>> On 24/03/2016 18:10, Steven D'Aprano wrote:
>>> On Fri, 25 Mar 2016 12:01 am, BartC wrote:
>>
>>>
>>> Then those numbers are pointless.
>>
>> Yes, they would need some adjustment to do this stuff properly.
> 
> Please give up before you get sued by the families of the people who 
> have died laughing.

Mark, please stop with the disparaging remarks.  Just ignore this thread
since it bother's you so much.  Whether or not you or anyone else
disagrees with Bart's programming techniques, his use of Python, or
anything else, this is no excuse for name disparaging remarks.  If Bart
doesn't wish to learn whatever it is you wish to teach, that's his
problem. I know you're a long-time poster to this list, but your
comments of late have been getting a bit inflammatory.  I am a bit
amazed that Bart is still willing to communicate on this list after the
flack he's got from you and a couple of others.  I applaud Steve's voice
of reason from time to time on this thread.

I've been trying to follow things on this thread, and I understand a bit
about Pythonic ideomatic style and I know what Python is really good at
and some of what it's not so good at, but it seems like one of Bart's
original contentions was that given a certain problem, coded in a
non-pythonic way, got slower under Python 3 than it was under Python 2
(if I recall correctly).  In other words a performance regression.
Somehow this seems to have gotten lost in the squabble over how one
should use Python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Michael Torrie
On 03/21/2016 06:43 AM, BartC wrote:
> On 21/03/2016 12:08, Ned Batchelder wrote:
>> On Sunday, March 20, 2016 at 9:15:32 PM UTC-4, BartC wrote:
>>>
>>> A tokeniser along those lines in Python, with most of the bits filled
>>> in, is here:
>>>
>>> http://pastebin.com/dtM8WnFZ
>>>
>>
>> Bart, we get it: you don't like the trade-offs that Python has made.
> ...
>> You don't like Python.  Can we leave it at that?
> 
> On the contrary, I do like it. It's just a shame it's made those 
> trade-offs as a bit more speed would have made it more useful to me.

Have you looked at compiled, python-inspired languages like Num
(http://nim-lang.org/). If it's syntax you like and some other Python
things like for the for loop works, maybe something like this would be
useful to you.

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Michael Torrie
On 03/22/2016 06:59 AM, BartC wrote:
> I'm not sure I follow. Your solution to dealing with the scenarios 
> raised by Steven D'Aprano is to:
> 
> (1) Not bother with exceptions at all inside the function

Correct, if your function is not equipped to handle this exceptional
circumstance and do the right thing, the right thing to do is let the
caller deal with it.  Otherwise debugging is very hard if not
impossible.  In your former example, a 0 return code means what exactly?
File not found? File exists but permission is denied?
> 
> (2) Not bother with them in the user code either

Again, it depends on whether the user code is equipped to react to the
exception and do the right thing.  I probably would catch file and i/o
errors like file-not-found and print a specific message out (or a dialog
box).  Or loop back to try again if the user was picking a file to work
with.

And despite the impression you may have gotten, it is appropriate to
look before you leap. Using os.exists() and other pre-flight checks are
appropriate.

> (3) Let any errors just crash out (raise a Python system error) (just 
> like I did in my original jpeg program which I was called out on)

Any exceptions your program is not explicitly equipped to deal with
should indeed bubble up to the OS and crash out.  After all it's by
definition an exceptional event and the state of your program and data
after this point is not reliable if such an event is ignored.  And it
provides valuable information an end user can pass back to you as a
developer to find bugs you missed.

> (4) Or if the user code does want to check for certain errors (like, 
> File Not Found, by far the most likely, and so that it can deal with 
> that and continue executing), it now has to go and dig out docs for ... 
> what? The user code needs to know what is going on inside the supposedly 
> opaque function it's calling.

Good documentation should describe exactly what exceptions a function or
library raises and why.  I tend to try to follow the example of Python's
standard library. I keep my exception classes few, and raise a good
error message with it.

But often times the exceptions we're talking about are standard Python
exceptions arising from things like I/O, not custom library classes.

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


Re: How to waste computer memory?

2016-03-19 Thread Michael Torrie
On 03/19/2016 02:38 AM, Steven D'Aprano wrote:
> On Sat, 19 Mar 2016 01:30 pm, Random832 wrote:
> 
>> On Fri, Mar 18, 2016, at 20:55, Chris Angelico wrote:
>>> On Sat, Mar 19, 2016 at 9:03 AM, Marko Rauhamaa  wrote:
 Also, special-casing '\0' and '/' is
 lame. Why can't I have "Results 1/2016" as a filename?
>>>
>>> Would you be allowed to have a directory named "Results 1" as well?
>>
>> If I were designing a new operating from scratch and didn't have to be
>> compatible with anything, I would probably have pathnames be tuples of
>> strings (maybe represented at the low level with percent-escaping),
>> rather than having a directory separator.
> 
> 
> ls -l /home/user/documents/stuff/foo
> 
> 
> ls -l "home","user","documents","stuff","foo"
> 
> 
> I think users of command line tools and shells will hate you.

Of course not.  Shells already associate specific meaning with certain
characters that can be used in file names.  For example the various
quoting characters, such as ' or ". These can be used in file names but
when referred to in the shell are escaped.  So it could be with path
separators. The file system itself could have no separators at all and
the shell could still use "/" to delineate the parts of the path on the
command line.  so

ls -l /home/user/documents/stuff/foo

would still work as would:

ls -l /home/user/documents/music\/fun/foo.

Even better directory delimiters could be set by an environment variable
(kind of like how sed lets you select a delimiter).

DIRSEP=|
ls -l "|home|user|documents|music/fun|foo"

This whole scheme breaks down when it comes to actually writing
programs, though.  Either you force all the libc apis to use lists of
strings for referring to paths (not so horrible but not
backwards-compatible), or you implement a similar escaping scheme in the
path names.  I think we'll stick with disallowing certain characters in
file names forever.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-18 Thread Michael Torrie
On 03/18/2016 02:26 AM, Jussi Piitulainen wrote:
> I think Julia's way of dealing with its strings-as-UTF-8 [2] is more
> promising. Indexing is by bytes (1-based in Julia) but the value at a
> valid index is the whole UTF-8 character at that point, and an invalid
> index raises an exception.

This seems to me to be a leaky abstraction.  Julia's approach is
interesting, but it strikes me as somewhat broken as it pretends to do
O(1) indexing, but in reality it's still O(n) because you still have to
iterate through the bytes until you find, say, the nth time that doesn't
raise an exception.  Except for dealing with the ASCII subset of UTF-8,
I can't really see any time when grabbing whatever resides at the nth
byte of a UTF-8 string would be useful.

> I work with text all the time, but I don't think I ever _need_ arbitrary
> access to an nth character. What I require is access to the start and
> end of a string, searching, and splitting. These all seem compatible
> with using UTF-8 representations. Same with iterating over the string
> (forward or backward).

Indeed, this is the argument from the web site
http://utf8everywhere.org.  Their argument is that often individual
unicode code points don't make sense by themselves, so there's no point
in chopping up a Unicode string. Many unicode strings only make sense if
you start at the beginning and read and interpret the code points as you
go. Hence UTF-8's requirement that you have to always start at the
beginning you want to find the nth code point is not a burden.

I guess whether or not you need to find the nth character depends on the
strength of string functions.  If I searched a string for a particular
delimiter, I could see it being useful to get whatever is just past the
delimiter, for example.  Though Python's split() method eliminates the
need to do that by hand.


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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-14 Thread Michael Torrie
On 03/14/2016 08:43 AM, BartC wrote:
> But how do you pass 'a' itself?
> 
> Perhaps you can say:
> 
>f('a')
> 
> and f can do some sort of lookup, if it knows the caller's context, for 
> such a name and retrieve the value that way. But that's rather 
> heavy-handed, and f can't distinguish between a reference to a name, and 
> a string.
> 
> Unless maybe you wrap this up in a class and  Well, you end up with 
> something that might emulate a name reference, but with so much 
> complexity and such overheads that it is not worthwhile.

Maybe, but I don't think so.  Is there really overhead in passing a
mutable object (a list) and working on it vs passing pieces of a list
one at a time? The lookup is the same, or maybe less.  In your example,
you have to do lookups for each item going into the function, and then
again when you assign the new values back into place in your source
list.  Passing the whole list into the function would seem to be faster.

> Yet, this is a feature I use extensively, far more often than I would 
> use mutable functions. And in fact it was used in the code for my jpeg 
> example, where in the Python I has to use a workaround (see below).

I think this is all just a matter of perspective. You seem convinced
that the C way is the only way to go from a performance standpoint. This
may or may not be true. There are certainly other paradigms. For example
functional programming disallows side-effects altogether. This allows
effortless chaining of functions, something you cannot do with your
function (subroutine really) that modifies things in place.  Maybe you
need to reexamine what your basic data structures are and need to be.
If you need a block of mutable values to do your processing on, perhaps
that should be encapsulated into its own set of routines.

Sounds like this is a case where you could alter your method to better
fit Python's strengths, rather than work around it's differences or
weaknesses compared to a language like C.

But it could be that Python is ill-suited to this kind of bit-twiddling
and that C is the proper place to do it (Chris has argued for this from
the beginning).


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


Re: Pyhon 2.x or 3.x, which is faster?

2016-03-11 Thread Michael Torrie
On 03/11/2016 03:24 PM, BartC wrote:
> On 11/03/2016 21:59, Mark Lawrence wrote:
>> On 11/03/2016 18:57, BartC wrote:
> 
>> def test():
>>  s=""
>>  for i in range(1000):
>>  s+="*"
>>  print (len(s))
>>
>> test()
> 
>> The minor snag that you might like to correct with your microbenchmark,
>> which any experienced Python programmer knows, is that you *NEVER, EVER*
>> create strings like this.
> 
> Why not? Chris said his version runs much faster (even allowing for 
> different machines), and might have a special optimisation for it.
> 
> And I think it can be optimised if, for example, there are no other 
> references to the string that s refers to.
> 
> So what's wrong with trying to fix it rather that using a workaround?

The act of "fixing" it, as you say, would change the semantics of the
language in a fundamental and major way.  Strings by definition are
immutable in Python.  If you need otherwise, there are other better
tools such as a buffer object of some kind, or StringIO which makes
file-like objects you can read and write to randomly.

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


Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Michael Torrie
On 03/07/2016 11:34 AM, BartC wrote:
> (I'm quite pleased with my version: smaller, faster, works on all the 
> Pythons, supports all 3 colour formats and no decoding bugs that I'm 
> aware of, and it's the first Python program I've written that does 
> something useful.)

I think you should be commended for writing it.  It may not be perfect,
nor is it necessarily "Pythonic" but you had fun doing it.  I hope you
aren't discouraged by the criticism of your code.

I hacked on it a bit, and it only took about a minute to change from
using arrays to immutable byte strings.  The only problem with that was
what I noted in my other reply.  That is that indexing a Python 2 string
gives a different result than indexing a Python 3 byte string.  I'm not
sure what kind of logic should be used to efficiently judge between
Python 2 and 3, and modify the answer accordingly.  In Python 2 I can
simply do "ord(fs.data[fs.pos])".  In Python 3 it's just
"fs.data[fs.pos]".  I'm not sure what kind of speed up using a normal
string provides vs the array.  But it has to be more a bit faster.

I suppose if others want to direct you in a more Pythonic path, they
could take your code and turn it into something that is more idiomatic
(and perhaps faster).  I may take a crack at it.

If it were me I think I'd make your jpeg decoder into it's own class,
and have it operate on any iterable input, be it an open file or
something else.  That may be actually slower though, but more pythonic.


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


Re: Pyhon 2.x or 3.x, which is faster?

2016-03-08 Thread Michael Torrie
On 03/07/2016 05:45 PM, Chris Angelico wrote:
> On Tue, Mar 8, 2016 at 11:22 AM, BartC  wrote:
>>
>> (Is a byte string the same as a byte array? Is a byte array the same as an
>> array.array? If I remove this line from my code, where 'data' has just been
>> read from a file:
>>
>>data=array.array('B',data)
>>
>> then it still works - Python 3. But not on Python 2. If I do .read on a
>> binary file I get a byte string in Python 3, but a string in Python 2. That
>> sort of mess.
> 
> The default string in Py2 *is* a byte string.

There are some interesting differences I found between a Python 2 string
(composed of bytes) and a Python 3 byte string, such as what you'd get
from calling read() on a file handle opened in binary mode.  That is in
Python 2, indexing a string returns a string of length 1.  In Python
3.5, indexing a byte string returns a value, the equivalent of calling
ord() on the single byte string.  This makes it a bit difficult to make
the code easily work between Python 2 and 3 and handle bytes.  Any ideas
there?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: creating zipfile with symlinks

2016-03-04 Thread Michael Torrie
On 03/04/2016 05:18 AM, Larry Martell wrote:
> Unfortunately very slow - around 8 minutes to zip a 7GB dir using the
> command line zip vs. 13 seconds with the python zipfile module.

And likely Python's zipfile is just giving up and storing the file
without compression.  What does unzip -v say about the compression on
the zip file you made with zipfile.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Everything good about Python except GUI IDE?

2016-02-28 Thread Michael Torrie
On 02/27/2016 11:13 AM, wrong.addres...@gmail.com wrote:
> On Saturday, 27 February 2016 18:08:36 UTC+2, Dietmar Schwertberger
>> As of today, there's no Python GUI builder comparable to VB 6.

> Thanks for stating this clearly. Everyone here has been trying to
> show me various ways to do the kind of things I will want to, but
> nobody clearly admits the limitations I will have to accept if I
> start with Python.

Every language and environment has limitations and tradeoffs, including
the venerable VB6 model.  In my opinion, no one including Microsoft has
ever duplicated the functionality of VB6.

> I am starting to wonder if VB.net would be a better solution for the
> time being. I have learnt enough VB.net to manage my work but it is
> bloated and Microsoft dependent.

Maybe you should post a small VB6 project on github (something that
isn't very secret and could be licensed in an open way perhaps) and then
see if we can come together here on the forum to convert it to Python
using one of the various GUI toolkits.  Could be a fun challenge and
would be instructive to you.

>> There are some like QtDesigner or wxGlade, but they either don't 
>> generate Python code directly or they can only be used if you know
>> the underlying toolkit good enough to create the GUI yourself. You
>> may try out some, but I can almost guarantee you that you will come
>> to the same result. If you want a GUI, create it yourself using
>> either wxPython or PyQt.
> 
> I will check it. I got the impression that you can create a GUI but
> that has to be converted to Python, and then you need a wrapper to
> put these forms in, and then they can be compiled or converted to
> *.exe with py2exe. Not a good way for development/debugging.

You are laboring under some misconceptions in general I think.  All the
GUI designers talked about here work with XML definition files (each has
its own flavor) and then either generate Python code from it, or you can
load the XML file at runtime and the GUI is created under the hood from
that (similar to .nib files on OS X).  Compiling to .exe is an entirely
different matter.  If you think Python will help you easily create .exes
you might be barking up the wrong tree.

Python is an interpreted language (soon to be JIT'ed with PyPy).  It's
not a compiler.  You can edit and run the python files directly for
debugging.  You can use py2exe to create a final executable if you want,
but this is not compiling and it won't keep your code secret.

> In the 1980s everyone was happy with inputs from the command line on
> a line editor, but today people expect GUIs with graphics and often
> even animations.

Qt does this very well with less and less programming all the time.
QtQuick and QML can define pretty nice transitions and animations that
can then be combined with Python programming.

But there's more than one way to do things.  I use a program called
Glade3 for doing GTK+ apps in Python (I only use Linux).  In PyQt I use
the amazing QtDesigner.

> It is surprising that a language which seems very popular does not
> have GUI development infrastructure in place these many years after
> it got into common use.

Well it's just that the infrastructure is very different than you're
used to.  There are lots of different choices.  I think it turns out
that a VB6-style IDE just has never been necessarily for the vast
majority of Python programmers.  And there are very fancy, complicated
GUI apps written in Python.  For example, the calibre ebook management
program is a nice GUI with animations like coverflow, and it's entirely
in Python and PyQt. I'm sure the author uses Qt Designer to do GUI layout.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Daemon strategy

2016-02-06 Thread Michael Torrie
On 02/06/2016 09:04 AM, paul.hermeneu...@gmail.com wrote:
> On Fri, Feb 5, 2016 at 4:10 PM, Ben Finney  wrote:
>> paul.hermeneu...@gmail.com writes:
>>
>>> On Fri, Feb 5, 2016 at 11:52 AM, Ben Finney  
>>> wrote:
 Since MS Windows lacks those facilities, ‘python-daemon’ can't use
 them.
>>>
>>> As you might imagine, I am not always able to specify which OS is
>>> deployed. That does not mean that I am not responsible for getting the
>>> work done. Perhaps you will tell me that what I want is not a daemon.
>>
>> I'm telling you none of those. What I'm telling you is MS Windows does
>> not support what is needed to make a Unix daemon.
>>
>> You may need to re-visit the requirements and negotiate something
>> different — a different deployment platform, or something which MS
>> Windows can do which is less than a proper Unix daemon.
> 
> I fully understand that Windows is not a proper UNIX. It might be that
> UNIX is not in each and every aspect a proper Windows.
> 
> If it is possible, I would like to create one tool to do this rather
> than multiple. Is there anything in Python that would help to
> accomplish this goal?

The fairly standard python-win32 package certainly allows you to make a
proper win32 service.  It's not part of the standard library, but you
could ship it with your package.

http://ryrobes.com/python/running-python-scripts-as-a-windows-service/

It's just not practical to have one tool that does such an OS-dependent
thing.  But it's not that hard to have specific code for Windows.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psss...I want to move from Perl to Python

2016-01-31 Thread Michael Torrie
On 01/31/2016 03:34 PM, Fillmore wrote:
> On 01/30/2016 05:26 AM, wxjmfa...@gmail.com wrote:
> 
>>> Python 2 vs python 3 is anything but "solved".
>>
>>
>> Python 3.5.1 is still suffering from the same buggy
>> behaviour as in Python 3.0 .
> Can you elaborate?

Sad to say jmf is a long-time troll on this list who seems to thinks he
understands Unicode better than he does.  We've been round and round
with him on this list over his issues and he's since been banned from
the email part of this list, but still spams the Usenet side from time
to time. If you're using NNTP, just add him to your kill file or block list.

There's nothing to elaborate on.  Python 3.5's integrated handling of
unicode is the best I've seen in any language.  It just works and you
don't need to worry about it (unlike most other languages), other than
to remember that anytime you take bytes into the program (say from a
file) they must be "decoded" into unicode, and whenever you write bytes
out (say to a file or socket) unicode strings must be "encoded" to a
desired byte encoding, such as UTF-8.  Python's in-memory representation
of unicode strings is correct (unlike Python 2.7, which had UCS-2 narrow
builds that can't handle non-BLM code points) for all unicode codepoints.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Michael Torrie
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> where the ... is the full original query. In other words, the whole
> query has to be run twice - once to assert that there's exactly one
> result, and then a second time to get that result. The existing
> algorithm ("try to fetch a row - if it fails error; then try to fetch
> another - if it succeeds, error") doesn't need to fetch more than two
> results, no matter how big the query result is.

Actually it occurs to me this doesn't have to be true.  The same
information he needs to know can be done with one query and only 1 result.

SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE
conditions

If the first column (or whatever you decide to alias it as) contains a
count, and the rest of the information is still there.  If count is 1,
then the row is what you want and you can do whatever you wish with it.
 If not, throw your exception.


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


Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Michael Torrie
On 01/30/2016 03:06 PM, Chris Angelico wrote:
> That actually violates the SQL spec. Some servers will accept it,
> others won't. (You're not supposed to mix column functions and
> non-column functions.) 

Are you sure?  Wikipedia is not always the most accurate place, but they
have several clear examples on the SQL page of combining table fields
with count() listed.  This is straight SQL we're talking about here, not
a particular implementation or dialect. Maybe there're some subtleties
at play here.

> It also can't cope with 'group by' queries, as
> it'll count the underlying rows, not the groups. I also suspect it
> can't handle join queries.

The Wikipedia entry on SQL, which seems to be based in some grounding of
the spec, shows that count(), joins, and group by are all compatible
with each other. So I dunno!

> The original approach is still the most general, and IMO the best.

Could be.  On the other hand, letting the DB do it all solves his
problem without mucking about with async iterators.

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


Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Michael Torrie
On 01/30/2016 02:57 PM, Michael Torrie wrote:
> SELECT count(some_id_field),field1,field2,field3 FROM wherever WHERE
> conditions
> 
> If the first column (or whatever you decide to alias it as) contains a
> count, and the rest of the information is still there.  If count is 1,
> then the row is what you want and you can do whatever you wish with it.
>  If not, throw your exception.

I'm not sure how SQLite handles it, or even what the SQL spec says, but
I know in MySQL you could do something like this:

SELECT count(id) as row_count,`tablename`.* FROM `tablename` WHERE condition

and get the same thing as SELECT * would have, with the addition of a
"row_count" field.  Note that because of the count() part, the query
will always only return 1 row. The fields will be NULL if the count was
zero or they will contain the fields from the last row the query found.
 In other words if there is more than one row that matches the query, it
will only give you data from the last match.

Now if Frank is hoping to do work on the first row and then throw an
exception if there's an additional row, then this of course won't work
for him.

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


Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Michael Torrie
On 01/30/2016 02:19 PM, Chris Angelico wrote:
> Efficiency. That's a fine way of counting actual rows in an actual
> table. However, it's massive overkill to perform an additional
> pre-query for something that's fundamentally an assertion (this is a
> single-row-fetch API like "select into", and it's an error to fetch
> anything other than a single row - but normal usage will never hit
> that error), and also, there's no guarantee that the query is looking
> at a single table. Plus, SQL's count function ignores NULLs, so you
> could get a false result. Using count(*) might be better, but the only
> way I can think of to be certain would be something like:
> 
> select count(*) from (...)

True. The id field is usually the best, or some other indexed field.

> where the ... is the full original query. In other words, the whole
> query has to be run twice - once to assert that there's exactly one
> result, and then a second time to get that result. The existing
> algorithm ("try to fetch a row - if it fails error; then try to fetch
> another - if it succeeds, error") doesn't need to fetch more than two
> results, no matter how big the query result is.

That is true, but that's what a database engine is designed for. Granted
he's just using SQLite here so many optimizations don't exist.  Just
seems a bit odd to me to implement something in Python that the DB
engine is already good at.  Guess ever since ORM was invented the debate
has raged over what the DB's job actually is.  Personally I trust a DB
engine to be fast and efficient much more than my Python code will be
playing with the results.





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


Re: Cannot step through asynchronous iterator manually

2016-01-30 Thread Michael Torrie
On 01/30/2016 01:22 AM, Frank Millman wrote:
> There are times when I want to execute a SELECT statement, and test for 
> three possibilities -
> - if no rows are returned, the object does not exist
> - if one row is returned, the object does exist
> - if more that one row is returned, raise an exception

Is there a reason you cannot get SQL to answer this question for you?
Something like:

SELECT count(some_field) WHERE condition

That will always return one row, with one field that will either be 0,
1, or more than 1.

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


Re: psss...I want to move from Perl to Python

2016-01-28 Thread Michael Torrie
On 01/28/2016 07:34 PM, Chris Angelico wrote:
> On Fri, Jan 29, 2016 at 1:06 PM, Paul Rubin  wrote:
>> Fillmore  writes:
>>> I look and Python and it looks so much more clean
>>
>> Yes it is, I forgot everything I knew about Perl shortly after starting
>> to use Python.
> 
> https://xkcd.com/353/
> 
> Particularly the hover text. :)

Another particularly appropriate xkcd comic, given the OP's experiencein
Perl is this one (and the hover text again!):
https://xkcd.com/224/

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


Re: How do I add 18 seconds to an ISO-8601 String in Python?

2016-01-23 Thread Michael Torrie
On 01/23/2016 07:22 PM, Robert James Liguori wrote:
> Thank you so much!  Btw, how do I convert back to ISO-8301?

Have a look at the documentation for the datetime module.  The docs will
tell you how you can convert to a string, formatted to your
specifications and needs.  As always, the documentation should be the
first place you look, followed by internet searches.

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


Re: how do I put the python on my desktop or even access it

2016-01-17 Thread Michael Torrie
On 01/17/2016 02:46 PM, eryk sun wrote:
> On Sun, Jan 17, 2016 at 9:03 AM, Michael Torrie  wrote:
>>
>> but if it's a text-mode program you must run it from cmd.exe like this:
>>
>> python \path\to\myprogram.py.
> 
> You only need to run from another console program to keep the window
> open after Python exits. You can even do that in other ways, but doing
> that is more complicated than it is useful.

Yes, but then we'll get the OP posting to ask why his python program
doesn't run. When he double-clicks his Py file it pops up briefly then
disappears! (Unless the code waits for user input of course).

> BTW, each console window is hosted by an instance of conhost.exe.
> There's nothing special about cmd.exe with respect to the console.

Of course, but I doubt very many people know about conhost.exe.  And
conhost.exe is rather useless in and of itself unless you have something
to run on it.  Thus the usual way to get a console window that you can
actually work with is to run cmd.exe.  I seriously doubt you would tell
a newbie to somehow use conhost.exe to run his program.

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


Re: Modify Settings window pop-up

2016-01-17 Thread Michael Torrie
On 01/17/2016 03:54 PM, Dennis Lee Bieber wrote:
> On Sun, 17 Jan 2016 16:52:52 -0500, Terry Reedy 
> declaimed the following:
> 
>> On 1/17/2016 12:13 PM, Arvind Vallabhaneni wrote:
>>>
>>> [cid:888c5934-3c75-43d8-9e76-59a9dfbef814]
>>
>> What is this?  When I mouse over, Thunderbird just says 'about: blank' 
>> on the status line.  I will not click on something so unknown.
> 
>   Never having seen the format before either, I'm going to make a WAG and
> think that GUID is a "Clipboard ID", rather than the contents of the
> clipboard itself...

It's what happens when a multi-part email message goes through the
Usenet gateway I guess.  cid notation is used in html email to link to
an attached imaged in an email.

To the OP: email attachments generally don't work on this usenet
newsgroup and mailing list.

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


Re: how do I put the python on my desktop or even access it

2016-01-17 Thread Michael Torrie
On 01/16/2016 01:11 PM, zack fitzsimons wrote:
> 
> 
> 
> 
> 
> 
> 

I'm assuming based on your empty email that you must be running Windows.
 Python is a command-line program.  First run cmd.exe and then from
there you can run python.exe and interact with it in immediate mode.  To
create and run python programs, you can use a text editor to make the
program, and then, if it's a graphical program, you can double-click it,
but if it's a text-mode program you must run it from cmd.exe like this:

python \path\to\myprogram.py.

There is a graphical integrated development environment that comes with
Python called IDLE that you can run from the start menu. I suspect this
is where you'll want to go first.

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


Re: wxpython strange behaviour

2016-01-16 Thread Michael Torrie
On 01/15/2016 05:58 PM, Shiva Upreti wrote:
> 
> What kind of further details do you want? Please tell me and i will try my 
> best to provide them.

As always, post a small but complete example test program (no more than
20 lines of code) that has the problem.  Paste it in such a way that one
can copy and paste it into an editor and get a validly-formatted
program.  Also post the traceback you get when you run the test program
you created.  Another person has to be able to replicate the problem to
advise you. Often in the process of doing this, people find their own bugs.


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


Re: Stop writing Python 4 incompatible code

2016-01-16 Thread Michael Torrie
On 01/16/2016 11:00 AM, William Ray Wing wrote:
> It was known at the time. It was certainly known by the companies
> that were ripped off, but they were typically small to really small
> and couldn’t get traction for their stories in a press that was in
> thrall to Microsoft.  It was pretty much only mentioned by contrarian
> writers like Cringely, and for the most part was lost in the noise
> over the browser war.

Stac, the company who Microsoft ripped off to make DoubleSpace, did
successfully sue MS and won (fairly big time).  MS ended up paying them
a fair sum of money in damages.  But it was too late by then. Stac's
original product, and MS DoubleSpace, was no longer really in demand  as
hard drive prices fell and speeds increased.  Stac moved onto reinvent
itself a few times, probably saved by the money MS gave them for
damages.  Eventually though Stac became Previo, and then disappeared for
good, selling its assets to Altirius. I am not sure Stac's destiny would
have changed had MS not ripped them off, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 08:29 PM, Rick Johnson wrote:
> Of course. But when you leave things open for speculation,
> you enviably create a situation where rumors can start
> circulating. GvR is not just any "John Doe" engineer, no,
> he's the head of an open source community, and the community
> has a right to be concerned about the livelihood and well
> being of their leader.

The only one speculating is you.  Everything I've read points to this
idea of yours about GvR and Google being untrue.  You have presented no
evidence for your accusation, so given the evidence I have seen that
contradicts you, I must conclude that you made it. That's the part I
take issue with and why I stopped to feed the troll, much to the chagrin
of everyone else.

> We have a *RIGHT* to be worried Chris, because our livelihoods are
> directly dependent on Python.

I don't know who the "we" you're talking about is, but if your
livelihood depends on Python's existence and development in a certain
direction, then I suggest you hire GvR--that's what Dropbox did and they
don't seem too worried about Python's future.  Python's doing just fine,
but you should be able to adapt to any programming language suitable for
your job at hand.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 06:02 PM, Rick Johnson wrote:
> In fact, in the years before Python3 arrived, it had enjoyed
> a steady ascension from obscurity into mainstream hacker
> culture, but now, all that remains is a fractured community,
> a fractured code base, and a leader who lost his cushy job
> at Google -- of which i think Python3 is directly
> responsible. Think about it: if they hired him *BECAUSE* of
> Python's success then we can *ONLY* conclude they fired him
> for mismanaging it.

Hmm, so Guido moved to Dropbox because Google fired him?  Interesting
revisionist history there.  I can find zero evidence to support your
assertion, so we can *ONLY* conclude that you are making stuff up.
Dishonesty is a harsh accusation, but when one makes up stuff to support
one's argument, is that not lying?

Besides that, people leave good jobs all the time for other more
challenging jobs.  Who says it was cushy?  Cushy because Google paid him
to work on Python?  Sounds like the move to Dropbox suited him just fine
and he and Python are both doing well. I'm sure there were contributing
factors to his decision to leave Google, like Google's NIH syndrome
(golang, dart, etc).  Things happen.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Stop writing Python 4 incompatible code

2016-01-13 Thread Michael Torrie
On 01/13/2016 06:02 PM, Steven D'Aprano wrote:
> Or we're too busy dealing with rising sea levels, crop failures, antibiotic
> resistant diseases, chaotic mass migrations, terrorists, wars for control
> over resources like water, and the collapse of the corporate state to care
> about such little things as upgrades to programming languages.
> 
> Or the AI singularity arrives and "human programmer" becomes as obsolete
> as "flint knapper".

Most likely, given your apocalyptic scenarios, flintknapping will become
an essential skill again!

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


Re: [Python-ideas] Password masking for getpass.getpass

2016-01-13 Thread Michael Torrie
On 01/13/2016 05:47 PM, Steven D'Aprano wrote:
> What of the poor souls who, for whatever reason, can't use NoScript?
> 
> What about those who are so frustrated with trying to get sites to work that
> they just Allow All On This Page? I've seen websites that rely on anything
> up to forty or fifty externally hosted scripts just to get basic
> functionality. (I stopped counting after a while and just kept
> clicking "Temporarily Allow...") You have external scripts calling out to
> external scripts from completely different domains, each more and more
> dodgy-looking than the last. And that's just the "legitimate" (for some
> definition of) scripts.

I seriously doubt there are any web pages that rely on 40 or 50 external
scripts for *basic* functionality.  But I have seen pages that load
dozens of external scripts for tracking, ad, and other purposes.  With
Ghostery I disable almost all of them and guess what, the pages load
faster and work just fine.  I think some companies must think, hey if
one analytics site is good, then 10 are better!  I've seen pages that
refused to load because some analytic script's hosting server was not
responding.  I highly recommend everyone run Ghostery and turn off
nearly all external scripts.  Doesn't usually affect the page's function
itself.  If anything it's educational to see how many external scripts
sites use these days. No wonder we have so many security issues.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-11 Thread Michael Torrie
On 01/11/2016 04:45 PM, Travis Griggs wrote:
> As a long term OO purist practitioner, I would add to this.
> Obviously, you can organize your code any way you want, with or
> without classes. You could put all your functions with an odd number
> of letters in one class, and all of the even numbered ones in another
> class.

And of course in Java you have to use classes for namespaces and
organization.  In python, the equivalent is simply a module.  It's
essentially a singleton object without having to do any boiler plate.  A
module can even keep state, so long as you only need to keep track of
one instance or set of states at a time.

> Having listened to the guy (Alan Kay) who coined the term (Object
> Oriented Programming) quite a bit over the years, I believe that the
> focus of OO (of which classes are a particular implementation
> approach) is to bind behavior to data. In “traditional” programming
> approaches, one focused on the algorithm (behavior) first, and then
> figured out what data needed to flow where to get the job done.
> Classes provided a mechanism to turn that equation, generally
> speaking, around. One thinks about the data first, and then figures
> out what behavior binds best to that data. And how that data will
> interact (inter-object behavior, often called messages) to get your
> job done. For some (many) problems, this can be a real win. And for
> some, not so much.
> 
> I think, this is often why, for a simple script, OO just kind of gets
> in the way. You have a straightforward procedure that you just want
> to do. The state (data) is not rich enough to make making it the
> focal point of your program.

The beauty of Python is that you can program procedurally, and still
work with objects as needed.  Every data type in Python is some kind of
object and you can call appropriate methods on those objects.  Even if
you do no OOP programming yourself.  For example,

some_string = "foo:bar"
(a,b) = some_string.split(':')

The ease with which Python can be used in many programming paradigms is
one reason I like Python so much.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: When I need classes?

2016-01-10 Thread Michael Torrie
On 01/10/2016 12:29 AM, Arshpreet Singh wrote:
> Hello Friends, I am quite new to OOP(object oriented Programming), I
> did some projects with python which includes Data-Analysis, Flask Web
> Development and some simple scripts.
> 
> I have only one question which is bothering me most of the time, When
> I will get the need to use Classes in Python? Or in other way is
> there any real-life example where you can tell me this
> problem/solution is kind of impossible in Python without Classes?

I can't speak to Flask or any other web development.  But for simple
scripts, I'll start out with no classes.  Just functions as needed, and
some main logic.  I always use the idiom:

if __name__ == '__main__':
# do main logic here

This way I can import functions defined in this script into another
script later if I want.

If I find I need to share state between functions, and if I find that I
might need to have multiple situations of shared state possibly at the
same time, then I will refactor the script into a class.  Despite the
apparent shame of using global variables, if I need to share state
between functions, but I cannot ever foresee a time when I'll need to
have multiple instances of that state, then I'll just use a module-level
global variable and continue to use normal functions, rather than define
a class.  In the parlance of OOP, this use case would be referred to as
a "singleton" and a python module (a script) is a form of singleton
already, even without using classes.

In the end my code often is a mix of classes and non-class -based code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Strange crash while running a script with a embedded python interpreter

2016-01-08 Thread Michael Torrie
On 01/08/2016 09:18 AM, Rickard Englund wrote:
> First, some system info
> * Windows 7 (also tested on 8 and 10) 
> * Python 3.5.1 64bit (previously also tested using several 3.x versions)  
> (also tested with 32 bit, but with 3.4.2) 
> * Microsoft Visual Studio 2015 (earlier version of python also tested with 
> Visual Studio 2013)  

Are you using the same version of Visual Studio that Python itself was
compiled with?  If not there can be subtle problems with incompatible
msvcrt dlls.  No idea if this would be contributing to the problem or
not, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyFladesk :: create GUI apps by Python and HTML, CSS and Javascript.

2016-01-08 Thread Michael Torrie
On 01/07/2016 08:54 PM, jacob Kruger wrote:
> I would definitely like to try out something like this - I am primarily 
> a web developer, and, partly since am 100% blind, any form of GUI design 
> is at times an issue for me, whereas I have been working with HTML 
> markup layouts for almost 20 years now, but, which versions of python 
> should this work with, and, what does it actually then use to 
> generate/handle GUI interface? Ask since, some of the GUI frameworks are 
> not too accessible themselves.

This project is simply a web browser (qtwebkit) embedded in a bare
window that automatically loads a python-based web application you write
separately.  That's all it is.  It's not a GUI toolkit or even a
web-based GUI toolkit.  It's primary purpose is to allow you to wrap up
a Python-based web app (using Flask, but I have no doubt it could handle
Django) in a little self-contained package so you can run it as if it
were a standalone app. Kind of like how Google Chrome let's you take a
url and make a virtual app out of it.

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


Re: GitHub's “pull request” is proprietary lock-in

2016-01-04 Thread Michael Torrie
On 01/04/2016 03:21 AM, m wrote:
> W dniu 03.01.2016 o 05:43, Ben Finney pisze:
>> That and other vendor-locked workflow aspects of GitHub makes it a poor
>> choice for communities that want to retain the option of control over
>> their processes and data.
> 
> I'm also afraid that Github will make to git the same thing as Google
> did to Jabber/XMPP.
> 
> Decade ago, I had plenty of friends on my jabber contacts list. Next,
> Google made it's talk compatible with jabber, then my friends slowly
> migrated to gtalk, because if they used gmail anyway, then why not use
> it also for jabber?
> 
> And then Google turned off XMPP support and suddenly I lost ability to
> contact with 80% of my friends without having stupid hangouts running,
> or without falling back to email (which is not so bad BTW).

I use gtalk with Pidgin every day using XMPP.  So Google still supports
XMPP.  However what they stopped doing was allowing federated XMPP,
which pretty much breaks XMPP, at least the spirit of it.  So the only
way to chat with gtalk users is to use your gtalk account.  But you
certainly don't need hangouts.  XMPP works fine between your client and
the Google server.

I agree that Google really pulled a bad one with gtalk though.  Dropping
federated XMPP support was definitely not in keeping with their original
"do no evil" mantra.

> The same can be with Github and git. PPL will forget how to use git
> without github. When Github will make git-incompatible changes, vast
> majority will need/want to follow the changes and eg. will use Gitlabs
> propertiary binary.

Yup you are correct.  However for the foreseeable future, you can still
do a git clone from github, and you can still use your local repository
normally.  In fact I think this is really part of the github workflow.
But who knows what the future will bring.  I can sure see the wisdom of
the GPLv3 as we move into a world of software as a service, where even
Microsoft uses Linux, and charges us for it.

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


Re: GitHub's “pull request” is proprietary lock-in

2016-01-03 Thread Michael Torrie
On 01/03/2016 05:51 PM, Random832 wrote:
> Just as a general comment, I note there are now at least four mangled
> versions of this subject header, and threading is already fragile enough
> on this list.  I think in the future it would be best to avoid non-ASCII
> characters in subject lines.

I noticed this too. Though threading based on message-id is working
quite well, as designed!

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


Re: GitHub's �pull request� is proprietary lock-in

2016-01-03 Thread Michael Torrie
On 01/03/2016 08:09 AM, Bernardo Sulzbach wrote:
> On Sun, Jan 3, 2016 at 1:05 PM, Michael Torrie  wrote:
>> kernel development is now exclusively on github.
>>
> 
> No it is not. If they have (now) 88 PR is because people don't RTFM.

Good to know.

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


Re: GitHub's �pull request� is proprietary lock-in

2016-01-03 Thread Michael Torrie
On 01/02/2016 09:56 PM, Michael Vilain wrote:
> Seriously, don't like git and the gitflow, find a project where they do 
> things more to your liking.

I do like git and the git work-flow.  Seems like github is doing an
end-run around several of the key features of git and the git work-flow
to keep people from going outside their environment.  This is definitely
not the work flow Linus originally had in mind, though he is not
terribly upset about it all as I think kernel development is now
exclusively on github.

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


Re: We will be moving to GitHub

2016-01-02 Thread Michael Torrie
On 01/01/2016 11:43 PM, Steven D'Aprano wrote:
> On Sat, 2 Jan 2016 07:09 am, Chris Angelico wrote:
> 
>> Yes, git is a capable tool. But so is Mercurial, and the arguments
>> weren't primarily based on differences in functionality (which are
>> pretty minor). It's mainly about the network effect.
> 
> You call it the network effect. I call it monoculture.

Indeed. The whole purpose of git is to allow development to be
distributed.  Is it a matter of hosting space?  Is it too expensive for
python.org to host their own public-facing git repository?  Especially
if python.org has no plans to use github's issue tracker this move makes
little sense to me.  A pull request can be made from any developer's own
git repository without github, or even from github if other developers
really want to work there.

I can understand why OSS projects like github given its complete
project-management options.  But if it's just the repository you're
after, I get far more mileage from my own locally-hosted git
repositories.  It's not at all hard to push to a read-only public http
git repository.  Pull requests can be made against individual
developers' http repos or hosted git providers.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: We will be moving to GitHub

2016-01-02 Thread Michael Torrie
On 01/02/2016 12:02 AM, Ben Finney wrote:
> What is being done to stave off the common response, addressed by GitHub
> users to people submitting a change as a link to their Git repository,
> of “can you please submit that as a GitHub pull request”?
> 
> That common response makes for an unnecessary and IMO unacceptable
> pressure toward centralisation. GitHub's “pull request” workflow is
> entirely proprietary and can only be done within GitHub.

Really?  This seems like an entirely artificial github requirement.
There's absolutely no reason why github couldn't do a pull request from
any arbitrary, valid git url.

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


OT: citizens and countries - was Re: v3.5.1 - msi download

2015-12-22 Thread Michael Torrie
On 12/22/2015 07:06 PM, jf...@ms4.hinet.net wrote:
> Mark Lawrence at 2015/12/21 UTC+8 8:50:00PM wrote:
>> My fellow Pythonistas, ask not what our language can do for you, ask
>> what you can do for our language.
> 
> When I saw this sentence, I can't resist to think of the famous lie created 
> by president John kennedy: "Ask not what your country can do for you, ask 
> what you can do for your country".
> 
> A COUNTRY WAS BUILT TO SERVE THE PEOPLE!!!
> 
> Do you think people are so boring that they have to build a country to serve 
> to?

In the American way of thinking, the country *is* the people.  So it was
neither a lie nor a bad thing that Kennedy proclaimed.  Maybe this is
not true for other countries, but I think most Americans would feel it
is true for their country.  And indeed the sentiment that Kennedy
expressed resonates deeply with many/most Americans. A country is only
made great by citizens willing to do many things for the good of the
country and their fellow citizens.

A country in which citizens only expect things from the country and
never think about their ability to change and benefit the country is a
week country indeed.

I say this as a someone not from the US.

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


Re: Need help on a project To :"Create a class called BankAccount with the following parameters "

2015-12-19 Thread Michael Torrie
On 12/19/2015 05:41 PM, Mark Lawrence wrote:
> On 19/12/2015 23:19, malitic...@gmail.com wrote:
>> you are absolutely correct Mark
>> i'm a beginner in python and  from the original question and test case given 
>> above i wrote this
>>
>> class BankAccount(object):
>>  def __init__(self, initial_balance=0):
>>  self.balance = initial_balance
>>  def deposit(self, amount):
>>  self.balance +=amount
>>  def withdraw(self, amount):
>>  self.balance -= amount
>> my_account = BankAccount(90)
>> my_account.withdraw(1000)
>> if my_account.balance < 4:
>>  print('invalid transaction')
 ^^
This code probably belongs in the withdraw() method.

>> class MinimumBalanceAccount(BankAccount):
>>  def __init__(self, MinimumBalance=4):
>>  self.minbalance = MinimumBalance
>>
>> after executing this i got this  TEST SOLUTION ERROR which i don't know what 
>> it means
>>
>> {"finished": true, "success": [{"fullName": "test_balance", 
>> "passedSpecNumber": 1}, {"fullName": "test_deposit", "passedSpecNumber": 2}, 
>> {"fullName": "test_sub_class", "passedSpecNumber": 3}, {"fullName": 
>> "test_withdraw", "passedSpecNumber": 4}], "passed": false, "started": true, 
>> "failures": [{"failedSpecNumber": 1, "fullName": "test_invalid_operation", 
>> "failedExpectations": [{"message": "Failure in line 23, in 
>> test_invalid_operation\nself.assertEqual(self.my_account.withdraw(1000), 
>> \"invalid transaction\", msg='Invalid transaction')\nAssertionError: Invalid 
>> transaction\n"}]}], "specs": {"count": 5, "pendingCount": 0, "time": 
>> "0.65"}}
>> -910
>> invalid transaction
>>
>> SO please what is wrong with my code, does it not meet the requirement of 
>> the "test case" given above in the question?
>> Thanks in advance
>>
> 
> It's a start but you've still left things out.  If I run your code as 
> given above it outputs "invalid transaction", exactly as expected.  So 
> how are you running the code?  Where does the extra output you give 
> above come from, presumably the "test case", whatever that might be?

While the output is as we'd expect, the program's logic is probably
wrong.  Would not you want to put that logic in the withdraw method to
prevent an invalid transaction?

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


Re: Python variable assigning problems...

2015-12-11 Thread Michael Torrie
On 12/11/2015 11:05 AM, ICT Ezy wrote:
> Deat Ian, Thank you very much your answer, but above answer from
> Robin Koch and your answer is different. What's the actually process
> here? I agree with Robin Koch, but your answer is correct. Pl explain
> differences ?

If you go re-read the answers, you'll find Ian has explained why Robin
was incorrect, and Robin acknowledged he got it wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python variable assigning problems...

2015-12-11 Thread Michael Torrie
On 12/11/2015 11:00 AM, ICT Ezy wrote:
> Thank you very much your answer, I had not known assignment id Right2Left 
> before. I done it.

Except that Robin was mistaken.  Assignment is indeed left to right,
though what's being assigned is on the right.

> 

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


Re: Administrators and moderators of Python-list, please erase all the messages that I not should have posted here in python-list!

2015-12-10 Thread Michael Torrie
On 12/10/2015 07:44 AM, françai s wrote:
> Administrators and moderators of Python-list, please erase all the messages
> that I  not should have posted here in python-list.
> 
> I ask this because I probably be in future a good programmer famous and I
> do not want to talk about the topics that I should not have posted here in
> python-list.
> 
> I decided prevent substantial harm to important relationships that probably
> I will have in future with other developers.

Just FYI again here, when I search for your email address on google, the
first few entries are your posts to several other mailing lists and
usenet groups making this same request.  I'd say that that honestly
looks far worse, from an internet search pov, than anything you might
have said on the mailing lists in a technical vein.  Good luck.

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


Re: Administrators and moderators of Python-list, please erase all the messages that I not should have posted here in python-list!

2015-12-10 Thread Michael Torrie
On 12/10/2015 07:44 AM, françai s wrote:
> Administrators and moderators of Python-list, please erase all the messages
> that I  not should have posted here in python-list.
> 
> I ask this because I probably be in future a good programmer famous and I
> do not want to talk about the topics that I should not have posted here in
> python-list.
> 
> I decided prevent substantial harm to important relationships that probably
> I will have in future with other developers.

While the folks who run the python.org archive do try to respond to
people's requests for removal, particularly in the case of libelous and
abusive messages, be aware that this list is also connected with the
large, decentralize usenet message system, and also is archived by
numerous newsgroup archiving web sites, and removal from the archive
hosted at python.org will not remove messages in those other places.

What could you have possibly said that would cause substantial harm to
future relationships?  Also, how are the web masters supposed to know
what you shouldn't have posted and what was okay?

I have read this mailing list for years now, and I don't recall having
seen anything from your email address that would be cause for concern.
I'm sure potential employers and colleagues can understand that you once
didn't know as much about Python and programming, and that you've
learned and become a better programmer over the years.

In short, I wouldn't worry about this at all if I were you (unless you
are PointedEars, RR, or our resident unicode troll). I'd worry far more
about social networks than the python mailing list.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting data out of Mozilla Thunderbird with Python?

2015-12-09 Thread Michael Torrie
On 12/09/2015 04:11 AM, Steven D'Aprano wrote:
> Maildir is also *much* safer too. With mbox, a single error when writing
> email to the mailbox will likely corrupt *all* emails from that point on,
> so potentially every email in the mailbox. With maildir, a single error
> when writing will, at worst, corrupt one email.
> 
> Thanks Mozilla, for picking the *less* efficient and *more* risky format as
> the default. Good choice!

Not so long ago, many filesystems were very poor at storing lots of
small files. For disk efficiency, storing them in one big file,
periodically compacting the file, was seen as a better way to go. After
all mbox format has been around for a very long time for certain reasons
(which no longer exist today). Maildir came later.  Back when hard
drives were smaller, it was also not uncommon to run out of inodes in a
file system on a server that had many small files.

Neither of these issues is much of a problem these days.  Ext4 added the
ability to store small files right in the inode, so internal
fragmentation (and wasting of space) isn't a big issue anymore.

It's good to know I can configure Thunderbird to use maildir for local
storage.  I'll have to make the change here.  Will make my backups a lot
easier and faster.

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


Re: Accessing container's methods

2015-12-07 Thread Michael Torrie
On 12/07/2015 11:10 AM, Tony van der Hoff wrote:
> Hi,
> 
> I have a class A, containing embedded embedded classes, which need to 
> access methods from A.
> .
> A highly contrived example, where I'm setting up an outer class in a 
> Has-a relationship, containing a number of Actors. The inner class needs 
> to access a method of the outer class; here the method get_name.
> 
> I don't really want to make Actor a sub-class (is-a; it isn't) of Monty; 
> that would raise all sorts of other problems.
> 
> Can anyone please advise me on how to achieve this magic?

You could add an attribute to each embedded object that provides a
reference back to the container object.

All in all, this design has a kind of smell to it.  Would it not be
better to ask the container class for information about the children,
rather than the other way around?  If a piece of code holds a reference
to the child object then it must also by definition hold a reference to
the container object, so why can't it ask the container object directly?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can I export data from a website and write the contents to a text file?

2015-11-20 Thread Michael Torrie
On 11/19/2015 12:17 PM, Patrick Hess wrote:
> ryguy7272 wrote:
>> text_file = open("C:/Users/rshuell001/Desktop/excel/Text1.txt", "wb")
>> [...]
>> It doesn't seem like the '\n' is doing anything useful.  All the text is 
>> jumbled together.
>> [...]
>> I finally got it working.  It's like this:
>> "\r\n"
> 
> The better solution would be to open text files in actual text mode:
> 
> open("filename", "wb")   # binary mode
> open("filename", "w")# text mode
> 
> In text mode, the correct line-ending characters, which will vary
> depending on the operating system, are chosen automatically.

It's not just a matter of line endings. It's a matter of text encoding
also.  This is critical in Python3 where everything is unicode and
encoding is essential.  You have to to use the text mode when writing
files here, and it's also a good idea to specify what encoding you wish
to write with (UTF-8 is a good default).

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


Re: What is a function parameter =[] for?

2015-11-19 Thread Michael Torrie
On 11/19/2015 02:21 PM, BartC wrote:
> (Python returns 42; so that means my languages are more dynamic than 
> Python? That's hard to believe!)

It tells me your language does late binding for default arguments, which
does mean the default argument can dynamically change at call time,
which would surprise me if I didn't know about it.  Either form of
binding is acceptable, and I don't think it makes a language more or
less dynamic.  Of course as Chris and Laura have said, a list as a
default parameter throws people off because of the semantics of
mutability, and the fact that Python's variable model does not follow
the traditional memory box model used in compiled languages like C.

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


Re: Writing a Financial Services App in Python

2015-11-19 Thread Michael Torrie
On 11/19/2015 09:20 AM, Cai Gengyang wrote:
> Sure ... is this : https://www.codecademy.com/learn/python a good
> place to learn Python ?

Why not have a look first at the many tutorials, including the ones on
Python's web site?  You need to explore feasibility first before you go
too far. Python is not the only language out there. I happen to like it,
but there are other popular choices.  An experienced developer can pick
up and program in any language very quickly.

Also you need to know a lot more than just programming in Python.  You
will need to know the various web development technologies and languages.

I don't say this just to discourage you up front.  I say this from a lot
of sad experience.  Your goals are *very* ambitious.  I've seen fairly
straightforward web apps stretch out into years and many tens of
thousands of dollars with whole teams of programmers.  And it does not
appear you have any programming experience at all yet.

Forget about a web app for now.  Work on the pieces like the algorithms
needed for doing the analysis you require.  Do some simple programs that
only do console input and output.

> Are you wanting to contract with some programmers to create this
> application for you?  Eventually I will have to find programming
> co-founders and employees to create and iterate the product as user
> feedback streams in. But I will write the initial prototype myself
> because I plan to be the main programmer / founder , but yes ...
> eventually I will need 1 or even 2 co-founders and when the platform
> gains enough users, we will have to hire programmers and sales/
> business people. But this will be a tech-heavy company and all the
> main founders and employees should be excellent programmers. But for
> the moment, I plan to write the initial prototype myself ...

Sounds ambitious! Hope you have a business plan in mind from the start.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: non-blocking getkey?

2015-11-19 Thread Michael Torrie
On 11/19/2015 08:48 AM, Ulli Horlacher wrote:
> 
> The focus is moved to another, unrelated window, but not back to the
> window in which the python scripts run. 
> Same behaviour on Linux (XFCE) and windows 7.

That's because an app that communicates with standard in and standard
out could be running over telnet, theoretically, so there would be no
window at all. There's absolutely no link in stdin and stdout to a
graphical window.  It's not even possible on Windows as the console
subsystem is completely separate from the GUI subsystem.  When your app
opens a Tk window, it's creating a brand new, top-level window, not
associated with any existing window.

One windows it might be possible to use the win32 api to enumerate the
windows, find your console window and switch to it.   Might even be
possible on Linux using raw X11 calls.







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


Re: Writing a Financial Services App in Python

2015-11-19 Thread Michael Torrie
On 11/19/2015 08:24 AM, Cai Gengyang wrote:
> It will be a web-based application.

Contract it out.  Or attract people who are interested in making an open
source application.  What you are thinking of is a massive undertaking.

Web-based application design is even more complicated than desktop app
design.  Web development involves many different languages.  Requires a
working knowledge of:

- Python programming
- a web framework for processing events like Django or web2py or
something similar
- html
- css
- SQL
- Javascript, including jquery and probably others

To say nothing of the algorithms necessary to implement the trend
analysis you speak of.

> I for example, am a terrible trader because of having almost zero 
> discipline and thus keep losing money.

Something tells me if the people you're trying to help have zero
discipline, then I don't think software is really going to help them.
Computers are just tools.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing a Financial Services App in Python

2015-11-19 Thread Michael Torrie
On 11/19/2015 04:59 AM, Cai Gengyang wrote:
> 
> From YCombinator's new RFS, This is the problem I want to solve as it
> is a severe problem I face myself and something I need. I want to
> write this app in Python as I heard that Python is a great language
> that many programmers use ... How / where do I start ? The problem is
> detailed below :

I'm afraid you're going to be discouraged.

Well the first step is you have to learn programming.  And you don't
start with such a large problem, I assure you.  You start by learning
the language by following the tutorials, writing small programs to
become familiar with programming and the language itself.  Then you
become familiar with related things like algorithms and data structures,
and how to use them with and from Python (or any language).  Eventually
you add to that graphical user interface development.

After that then you might be in a position to start thinking about how
to design and build a program that does what you were talking about.

There honestly are no shortcuts.  Python is a great language, and is
easy to learn, but it's not like you can start cranking out full-blown
applications magically.  In the hands of experienced programmers, yes
Python is incredibly fast and flexible for cranking out working apps.

You might try checking out a Python application development framework
that can produce apps that will run on Android and iOS (and Windows and
Linux) called Kivy.  I would think mobile should be your target platform
for such an app.

> 

> This seems to us like something software should help solve. We'd like
> to see teams tackling each of the component issues around saving and
> investing, along with ones tackling the entire package.

Are you wanting to contract with some programmers to create this
application for you?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Michael Torrie
On 11/14/2015 06:54 PM, fl wrote:
> Hi,
> 
> I see an example Python code has such a line at the file beginning:
> 
> #!python
> 
> 
> Is there some meaning about it?

Supposed to be, yes, but the line you've pasted there wouldn't work on
any system I know of.

https://en.wikipedia.org/wiki/Shebang_%28Unix%29

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


Re: Trying out Kivy

2015-11-14 Thread Michael Torrie
On 11/14/2015 04:51 AM, Cecil Westerhof wrote:
> I tried to install v1.8.0 with:
> pip3 install -I kivy==1.8.0

Why are you trying to install the non-current version of kivy?

Did you install pygame successfully?

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


Re: Question about math.pi is mutable

2015-11-13 Thread Michael Torrie
On 11/10/2015 03:03 AM, Antoon Pardon wrote:
> Op 10-11-15 om 00:29 schreef Ben Finney:
>>
>> Who is doing what to whom? The user of the library isn't doing anything
>> to the library author, so what is it the library author would consent
>> to? Instead, you seem to be trying to assert a *power* of the library
>> author to restrict the library user. Such a power is not granted by
>> Python.
> 
> Python is not at liberty to grant or deny such a power. Python is just
> a vehicle in which code is written. The author of a library can restrict
> its use anyway he sees fit.

No he cannot, outside the bounds of copyright law.  Why would you think
otherwise?  The only document that binds the end user in any way is the
copyright license, unless some other formal contract has been arranged.

>> Instead, the library author is obliged to treat the library user as an
>> adult who consents to the freedoms inherent to Python's design, and to
>> not restrict their use of the library needlessly.
> 
> There is no such obligation. And if it was an obligation, you can hardly
> talk about consenting. Consenting adults mean that either party can
> decide on conditions. Once one party is obligated it is no longer consenting.

You are correct there is no obligation, but nor does Python empower the
library developer.   He may attempt obfuscation or other means to
control the use of his library of course, but only copyright grants him
legal authority of any kind.

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


Re: More tkinter Madness

2015-11-13 Thread Michael Torrie
On 11/13/2015 12:14 PM, Tim Daneliuk wrote:
> On 11/13/2015 12:32 AM, Christian Gollwitzer wrote:
>> Apfelkiste:Sources chris$
> 
> Well, I get window and when I do this:
> 
> pack [button .b -text Hello -command exit]
> 
> Nothing appears.
> 
> tkinter appears borked
> 
> I have reinstalled once already, will try again

Tkinter is the name of the Python package for using Tk, but Tk itself is
usually called Tk (package on Fedora and RHEL is tk).

On my CentOS installs, in /usr/share/tk8.5/demos, there are a number of
Tcl/Tk demos you can run.  If Tcl and Tk are working, then I would move
to reinstalling tkinter.

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


Re: Trying out Kivy

2015-11-13 Thread Michael Torrie
On 11/13/2015 11:30 AM, Cecil Westerhof wrote:
> On Friday 13 Nov 2015 18:21 CET, Michael Torrie wrote:
> 
>> On 11/13/2015 09:33 AM, Cecil Westerhof wrote:
>>> I tried to install pygame and PIL with pip3, but that did not find
>>> anything. 
>>
>> The replacement for PIL is called Pillow. I'm not sure if it's a
>> drop-in replacement or not. If it's not, then you'd have to modify
>> Kivy to import from Pillow. Pillow does support Python3.
> 
> After installing Pillow the error about PIL disappeared, but I got new
> errors about bcm and x11.

Traceback?

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


Re: Trying out Kivy

2015-11-13 Thread Michael Torrie
On 11/13/2015 09:33 AM, Cecil Westerhof wrote:
> I tried to install pygame and PIL with pip3, but that did not find
> anything. 

The replacement for PIL is called Pillow.  I'm not sure if it's a
drop-in replacement or not.  If it's not, then you'd have to modify Kivy
to import from Pillow.  Pillow does support Python3.

> Is there another way to install those dependencies?

Did you do a search to find out a) if PyGame supports Python3 (it does)
and b) where to go to download the source code for it? (their home page)?

PyPi is nice, but it's not the only place you can get useful Python
modules from.

> But more importantly: can I develop with python3 for the Android?
> Because the primary reason to use Kivy is to develop applications for Android.

Again, did you do a quick Google search?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: More tkinter Madness

2015-11-12 Thread Michael Torrie
On 11/12/2015 05:25 PM, Tim Daneliuk wrote:
> On 11/11/2015 08:25 PM, Chris Angelico wrote:
>> On Thu, Nov 12, 2015 at 12:52 PM, Tim Daneliuk
>>  wrote:
>>> I am the author of twander (https://www.tundraware.com/Software/twander).
>>> This code has run flawlessly for years on FreeBSD, Linux, MacOS and
>>> Windows.  Some months ago, I put it on a couple of VPS servers (FreeBSD
>>> and Linux) and BOOM, it doesn't run.  I asked around here and got some
>>> suggestions and then did some homework.
>>>
>>> Traceback (most recent call last):
>>>   File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
>>
>> It's running here under Python 2.6. Sorry if this is a question you've
>> already been asked, but were you successfully running under 2.6
>> elsewhere? Might be a versioning issue.
>>
>> ChrisA
>>
> 
> It always ran OK on every previous version of Python from about 2.4 forward
> on VMs, physicals, *nix, OSX, Windows, etc.

And other X11 apps are working fine on the test VPS where your app
crashes? Other Tk apps?  Other Python Tk apps?

Your app runs fine on my VPS (Linode), running CentOS 7, Python 2.7.
Also runs fine on my CentOS 6 VM (also Linode), Python 2.6.6.

I also verified that if X11 forwarding is not working, Python reports an
exception "_tkinter.TclError: no display name and no $DISPLAY
environment variable" immediately, so that's definitely not your problem.



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


Re: Hi

2015-11-12 Thread Michael Torrie
On 11/12/2015 02:32 AM, Mark Lawrence wrote:
> On 11/11/2015 17:35, Cameron Houliston wrote:
>> Can I have a link to use python
>>
>> Sent from Mail for Windows 10
>>
> 
> I usually start with www.google.co.uk.

I think Windows 10 blocks Google. :)

And of course the official home of Python is https://www.python.org/

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


Re: Python.exe is not a valid Win32 application error message

2015-11-12 Thread Michael Torrie
On 11/11/2015 09:43 PM, Steve Hayes wrote:
> That is useful to know.
> 
> I get messages (from Glary Utilities) that some of my programs 
> (including Python) need to be updated, but when I've downloaded and 
> updated them, the update hasn't worked.

Such utilities seem to cause more trouble than they're worth.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to get 'od' run?

2015-11-11 Thread Michael Torrie
On 11/11/2015 08:21 PM, Michael Torrie wrote:
> On 11/11/2015 08:04 PM, fl wrote:
>> Hi,
>>
>> I am learning python. I see a previous post has such code:
>>
>>
>>
>>
>>
>>>>> data = '"binääridataa"\n'.encode('utf-8') 
>>>>> f = open('roska.txt', 'wb') 
>>>>> f.write(data) 
>>17 
>>>>> f.close() 
>>
>> The .encode methods produced a bytestring, which Python likes to display 
>> as ASCII characters where it can and in hexadecimal where it cannot: 
>>
>>>>> data 
>>b'"bin\xc3\xa4\xc3\xa4ridataa"\n' 
>>
>> An "octal dump" in characters (where ASCII, otherwise apparently octal) 
>> and the corresponding hexadecimal shows that it is, indeed, these bytes 
>> that ended up in the file: 
>>
>> $ od -t cx1 roska.txt 
>  ^^^
> This is most likely a bash prompt. Therefore "od" is a program on your
> computer.  Nothing to do with Python at all.
> 
> To get Python to display \x## hex codes for non-ascii characters in a
> byte stream, you can print out the repr() of the byte string.  For example:
> 
> print (repr(my_unicode_string.encode('utf-8')))

Also there are numerous recipes for doing standard hex dumps out there.
 For example,

http://code.activestate.com/recipes/142812-hex-dumper/
-- 
https://mail.python.org/mailman/listinfo/python-list


<    3   4   5   6   7   8   9   10   11   12   >