Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel

On 06/19/2013 02:50 AM, Jack Little wrote:

I compiled a program in python, but the second I open it, there is a flash of 
the error, but then the cmd window closes.



It compiles when you run it, so it's not clear what extra step you're 
describing here.


Quite a bit of missing information here, so let's do some guessing.

You're running some version of Windows?

You're running Python 3.3 ?

You're launching what you think is a useful program, directly from 
Explorer, using double-click, or with right-click-OpenWith ??  Python 
programs don't have an EXE extension, so perhaps you're not actually 
double clicking on the right thing.  Or perhaps you've neglected to 
change Windows brain-dead default of NOT showing file extensions in 
Explorer.


When a non-GUI program starts from Explorer, Windows helpfully creates a 
command window, then helpfully destroys it before you can read the 
results if any.


If you know your program is correct, and you just want to see the 
output, you'll need to put some form of pause at the end of your 
program.  This could be a sleep(3) if you're a speed reader, or it could 
be just an input() statement.


But if the program is flawed, such as a syntax error, you might never 
reach the pause.  So you might as well get used to the following:


Run your program at a cmd prompt, inside a "DOS Box", or "Command 
Window", or one of several other names used in various Windows versions. 
 It's actually a shell, but Windows doesn't use that term.


--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] jessica peters

2013-06-19 Thread jessica peters
 http://piranhadvertising.com/yi/eem/lbabm/kfghr/skhnig/uaozl.html
  jessica peters
 dtf/div>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] EXE Problem

2013-06-19 Thread Jim Mooney
On 18 June 2013 23:50, Jack Little  wrote:
> I compiled a program in python, but the second I open it, there is a flash
> of the error, but then the cmd window closes.
>

I suspicion someone as new to Python, since I am, who is using Windows
and getting the annoying Windows Flash ;') So in Detail:

Go to the Windows entry box on lower left > type   cmd   for the DOS
box > hit Enter  > type python followed by the full path to your
program.

For instance, I would type:

python c:/python33/jimprogs/sympystuff.py  and hit Enter

to see the printout of a program that illustrates a quadratic equation.

Note that after you type python, the input file is to the python
interpreter, which Doesn't need those nasty Windows backslashes, so
you should use forward slashes. I have no idea why Bill Gates thought
backslashes were kewl - maybe he has a really long right little
finger. Or he was trying to pretend DOS was a better variant of Unix
(hahahahahahahahahaha)

Then you should see the result, or your syntax errors. Which you
already did if you put   pause  at the bottom of your program. But
this eliminates the need to keep doing that.

After you see that, exit() from python back to the DOS box, then
simply type python, and you get the interactive python interpreter,
where you can fool around with basic python. You also get to see your
syntax errors realtime, rather than the annoying DOS Flash.

If you're not familiar with DOS, check out basic DOS commands on
Google - you may need them. Us old fogeys, and hardcore programmers,
know DOS, but I don't assume others do in a GUI-world

But putting input() right after your program is easiest.

As for sleep, as Dave mentioned, in case you didn't get to module
imports, create a simple program like this:

import time
time.sleep(3)

Or if you want to see more than a blank screen and wonder if sleep is working:

import time
print('time to go to sleep')
time.sleep(5)
print('darn alarm clock')

One can later use IDLE or Wing 101 for more complex programs (google
them), but it really is good to know how to use DOS first.

And if you're not using Windows, all this typing will be useful to
someone else. But Bayesian inference tells me you most likely are ;')


Jim
Sci-fi novel in one line:
Congratulations miss, you have twins - but one is dark matter.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] jessica peters

2013-06-19 Thread Jim Mooney
Just remember - the first three letters in Diet is DIE

I'll stick with my cheeseburgers ;')

Jim

On 19 June 2013 05:17, jessica peters  wrote:
> http://piranhadvertising.com/yi/eem/lbabm/kfghr/skhnig/uaozl.html
>
> jessica peters
> dtf
> /div>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Opinion - help could use more examples

2013-06-19 Thread Jim Mooney
Here's a peeve of mine about Python help - it often has zero examples.
I printed help(zip) to see what it does and got this:

  Return a zip object whose .__next__() method returns a tuple where
 |  the i-th element comes from the i-th iterable argument.  The .__next__()
 |  method continues until the shortest iterable in the argument sequence
 |  is exhausted and then it raises StopIteration.

Not understandable right off, IMHO, unless you're already hardcore.
Okay, I figured it out by running it with some iterables, so I didn't
have to google around looking for examples. It would have saved time
if there was just one example of what you would get from running
next() on a zip or number lists a few times, since it's a simple
concept. I'm coming from Jquery, which is chock full of examples, so
everyone from bankers to pimps (if there is a difference) can use it.
I think the name is confusing zip with compacting, too.

Although to be fair.
choosing_nth_item_from_parallel_sequences_until_there_is_no_match_on_n()
might be too much typing compared to zip() ;')

-- 
Jim
Sci-fi novel in one line:
Congratulations miss, you have twins - but one is dark matter.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Chris “Kwpolska” Warrick
On Wed, Jun 19, 2013 at 7:43 PM, Jim Mooney  wrote:
> Here's a peeve of mine about Python help - it often has zero examples.
> I printed help(zip) to see what it does and got this:
>
>   Return a zip object whose .__next__() method returns a tuple where
>  |  the i-th element comes from the i-th iterable argument.  The .__next__()
>  |  method continues until the shortest iterable in the argument sequence
>  |  is exhausted and then it raises StopIteration.
>
> Not understandable right off, IMHO, unless you're already hardcore.
> Okay, I figured it out by running it with some iterables, so I didn't
> have to google around looking for examples. It would have saved time
> if there was just one example of what you would get from running
> next() on a zip or number lists a few times, since it's a simple
> concept. I'm coming from Jquery, which is chock full of examples, so
> everyone from bankers to pimps (if there is a difference) can use it.
> I think the name is confusing zip with compacting, too.
>
> Although to be fair.
> choosing_nth_item_from_parallel_sequences_until_there_is_no_match_on_n()
> might be too much typing compared to zip() ;')

A short explanation might be

Iterate on arguments, if all return something yield whatever we
got, otherwise stop iterating.

But anyways, instead of using the built-in docs, refer to the
human-friendly documentation available on the web:
http://docs.python.org/3/library/functions.html?highlight=zip#zip

Downloads for those docs, if you believe this would be more convenient
for you, are available at http://docs.python.org/2/download.html and
http://docs.python.org/3/download.html (for Python 2 and 3
respectively)
--
Kwpolska  | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Jim Mooney
On 19 June 2013 11:02, Chris “Kwpolska” Warrick  wrote:

> But anyways, instead of using the built-in docs, refer to the
> human-friendly documentation available on the web:
> http://docs.python.org/3/library/functions.html?highlight=zip#zip

True, but usually built-in is quicker, although I wish I could get rid
of all the __garbola__ and get right to the methods ;')  As for
downloadable help, I have a chm file, and the Search is terrible. It
will turn up Everything that has any text with the world 'zip' in it,
including Zippy the Clown ;')  Using Index is a bit better but still
finds garbage you must sift through. So builtin help would be
preferable if it were just a bit less concise and had some examples.
It's only an opinion. The gods of Python may do otherwise as they
choose.

Jim
>
-- 
Jim
Sci-fi novel in one line:
Congratulations miss, you have twins - but one is dark matter.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help appending data to a logfile

2013-06-19 Thread Prasad, Ramit
Peter Otten wrote:
> Matt D wrote:
> 
> > Hey,
> > I wrote some simple code to write data to a logfile and it works pretty
> > well (thanks guys).  Now my problem is that every time i run the program
> > the old logfile.txt is overwritten.
> 
> The help() function in the interactive interpreter is a good tool hunt for
> help on features of functions and classes. For example:
> 
> >>> help(open)
> Help on built-in function open in module __builtin__:
> 
> open(...)
> open(name[, mode[, buffering]]) -> file object
> 
> Open a file using the file() type, returns a file object.  This is the
> preferred way to open a file.  See file.__doc__ for further information.
> 
> >>> help(file)
> Help on class file in module __builtin__:
> 
> class file(object)
>  |  file(name[, mode[, buffering]]) -> file object
>  |
>  |  Open a file.  The mode can be 'r', 'w' or 'a' for reading (default),
>  |  writing or appending.  The file will be created if it doesn't exist
> [...]
> 
> 
> > I need to be able to stop and start
> > the program without overwriting, or losing, the old data.  here is the
> > relavent code:
> >
> >  #  central part of the program
> >  #  lays out the GUI panel
> >  #  omitted lots for our purposes here
> >  Class panel(wx.Panel):
> >
> > #  open a file named "logfile.txt" in "w" writing mode.
> > #  this will create the file if it doesn't exist.
> > self.logfile = open('logfile.txt', 'w')
> >
> >  # Updates the TextCtrl field values
> >  # and logs TextCtrl field values
> >  def update(self, field_values):
> >
> > #logger code---
> > #first write the CURRENT date/time
> > self.logfile.write('%s,'%(str(strftime("%Y-%m-%d %H:%M:%S",
> > gmtime()
> > # loop through each of the TextCtrl objects
> > for k,v in self.fields.items():
> > #get the value of the current TextCtrl field
> > f = field_values.get(k, None)
> > if f:
> > #output the value with trailing comma
> >self.logfile.write('%s,'%(str(f)))
> > self.logfile.write('\n')
> > #end logger code 
> >
> > In addition to not deleting the old data, it would be awesome to have
> > some sort of wxPython widget that would give the user the ability to
> > 'save as', or name and save the file, from the GUI panel.
> 
> This last request is a bit vague, and I'm not a wxPython user myself -- but
> the wx.FileSelector() function seems like a good start.
> 
> Unfortunately the documentation I found is for the underlying C++ library:
> 
> 


I think he wanted:
http://www.wxpython.org/docs/api/wx.FileDialog-class.html 

> 
> May layman's translation into wxPython:
> 
> >>> import wx
> >>> app = wx.App()
> >>> wx.FileSelector("Save logfile as", flags=wx.FD_SAVE)
> [snip spurious warnings]
> u'/foo/bar.baz' # use that result for the actual saving.

If you want to do this, you need to run the wx.App() line only once per 
application run. You also need to store all the text that you were writing 
to file in a list because you cannot write to file and then decide the name
later. You must know location first and then write data. Data is not 
guaranteed to be written until the file is closed as it can stay in-memory
until a buffer is full and then gets written to file. Closing a file should
flush the buffer contents to file.

Dave Angel is correct. Look at the documentation for open() or just store 
the data in memory and only write when a user selects a save button/menu.


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-19 Thread Prasad, Ramit
Matt D wrote:
> >
> >
> > Also note, that unless you do self.logfile.close() it is not guaranteed
> > that the data is being written to file. I prefer to use the following
> > idiom for Python 2.6+ (might be in 2.5, but not sure offhand when it was 
> > added).
> >
> > with open('filename.txt', 'a') as f:
> > # write data
> >
> >
> Thanks!
> Now with some experience using this logger i have found that the items,
> while they may not be in an ideal order, are nonetheless always in the
> same order starting with date/time.  In the interest of getting this
> thing working ASAP the current ordering is acceptable for now; at some
> later time I may try to arrange into some other desired order.
> 
> I am testing the 'a' append mode now.  hoping this will allow for not
> overwriting existing data.
> 
> Where in the program do I put the:
>   self.logfile.close()
> Is there someway to trigger this from the UI? or even when the program
> is stopped?

A common way to trigger UI actions is a button whose callback calls that.
Or you can bind in an event hook for closing the window.

in __init__ add this line - 
self.Bind(wx.EVT_CLOSE, self.onExit)


def onExit(self, event):
   '''Run when closing'''
   self.logfile.close()
   self.Destroy() # Continue closing the app otherwise 
  # you will not be able to close it via UI


Although, exiting the program will probably close the file for you


If you are using append mode ('a') you can just do the following
which will append and close the file for you. 
with open(filename, 'a' ) as logfile:
logfile.write( data_string )


Make sure you add a newline ('\n') to what you write otherwise all 
your output will be on one line with no spaces

for x in xrange(15):
with open( filename, 'a' ) as f:
f.write( str(x) )

filename=
01234567891011121314
=


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Chris “Kwpolska” Warrick
On Wed, Jun 19, 2013 at 8:11 PM, Jim Mooney  wrote:
> As for downloadable help, I have a chm file, and the Search is terrible.

Get the sane html format, where the search is more useful.

--
Kwpolska  | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to redirect console output to a TextEdit box on a QT Python Gui ?

2013-06-19 Thread SM
Hello Chris, Thanks for your response. I have a follow-up question, if you
don't mind, to understand your answer better.
I am running a python3 script. So  first part of your answer applies here:

*"If the application you run is a Python script, import it, execute the
functions and have the data returned (as opposed to printing it), and
then you can do self.textEdit.setText(output_*
*goes_here)"*

My python script prints a lot of text at various stages. There are "print"
statements spread across multiple python files.  So when you say "have the
data returned" and "output_goes_here" as the argument of setText, I am a
bit confused as to how I can redirect multiple print statements to the
setText call. Can you please clarify?

Thanks!
Sm




On Sun, Jun 16, 2013 at 2:02 PM, Chris “Kwpolska” Warrick <
kwpol...@gmail.com> wrote:

> On Sun, Jun 16, 2013 at 7:15 PM, SM  wrote:
> > Hi
> > I have implemented a GUI using PyQt4/python3, which allows the user to
> > select a few files as command-line arguments. When I hit "OK" button, my
> > application runs and the output text is displayed on the terminal where I
> > run the python script. I would like to redirect this text to a TextEdit
> > window I have created on the GUI:
> >
> > self.textEdit = QtGui.QTextEdit(Form)
> > self.textEdit.setGeometry(QtCore.QRect(10, 300, 421, 141))
> > self.textEdit.setObjectName(_fromUtf8("textEdit"))
> >
> > Do you have any suggestions/tips as to how I can accomplish this task?
> Using
> > some suggestions online,  I tried creating a QProcess object and connect
> the
> > signal to a function which  reads the std output. But I don't know how to
> > set the arguments to the call "process.start".
> >
> > self.process = QtCore.QProcess()
> > QtCore.QObject.connect(self.process, QtCore.SIGNAL("readyReadStdout()"),
> > self.readOutput)
> > I know I have to call self.process.start here but am not able to find
> > examples of how to do it. One example online uses
> > "self.process.setArguments", but python3/pyQt4 doesn't seem to know about
> > it. Using the argument directly with process.start is not helping either.
> >
> > Appreciate any pointers. If there are better ways than what I am trying
> to
> > use, appreciate that as well.
>
> If the application you run is a Python script, import it, execute the
> functions and have the data returned (as opposed to printing it), and
> then you can do self.textEdit.setText(output_goes_here)
>
> If the application isn’t Python, use the (stock aka vanilla)
> subprocess module.  The easiest solution is:
>
> import subprocess
> self.textEdit.setText(subprocess.check_output(('command',
> 'argument1', 'argument2')))
>
> And you do that in the function that is called when you press OK.
>
> Bonus suggestion: do nice layouts instead of setting the coordinates
> manually.  The options you want are in the Form menu of Qt Designer.
> If you don’t do this, resizing windows is nonsense.
>
> --
> Kwpolska  | GPG KEY: 5EAAEA16
> stop html mail| always bottom-post
> http://asciiribbon.org| http://caliburn.nl/topposting.html
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to redirect console output to a TextEdit box on a QT Python Gui ?

2013-06-19 Thread Prasad, Ramit
SM wrote:
> Hello Chris, Thanks for your response. I have a follow-up question, if you 
> don't mind, to understand
> your answer better.
> I am running a python3 script. So  first part of your answer applies here:
> 
> "If the application you run is a Python script, import it, execute the
> functions and have the data returned (as opposed to printing it), and
> then you can do self.textEdit.setText(output_
> goes_here)"
> My python script prints a lot of text at various stages. There are "print" 
> statements spread across
> multiple python files.  So when you say "have the data returned" and 
> "output_goes_here" as the
> argument of setText, I am a bit confused as to how I can redirect multiple 
> print statements to the
> setText call. Can you please clarify?
> 
> Thanks!
> Sm

Usually your logic functions should not print (except for debugging). It should 
return
data which you can then wrap in a UI which prints or displays on GUI. He does 
not mean to 
actually redirect output but instead do each "stage" and then print/display the 
appropriate 
text *after* the task is done.

Instead of trying to redirect output you can try logging to file and having the 
GUI read that file
and print what is appropriate. 

You can also try to replace stdout with an in-memory buffer which you aggregate 
and then display after 
the stage (or at any point) like this (untested).

self.oldstdout = sys.stdout
sys.stdout = cStringIO.StringIO()
# Do processing stages
# And later
self.textEdit.setText( sys.stdout.getvalue() )
# Replace stdout if needed
sys.stdout = self.oldstdout


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Jim Mooney
On 19 June 2013 11:36, Chris “Kwpolska” Warrick  wrote:

>
> Get the sane html format, where the search is more useful.

That was actually "help"ful ;')  A lot better organized and you can
see things better than the tiny chm left-window font. Msoft sure fell
down on chm help. No wonder Google is kicking their butt. I'm big on
being able to see things. Programmers preach usability, then I see
endless websites that have gone with the new black-is-back style of
spidery gray text on a medium gray background that only Superman could
see. Arghhh! I'll be so glad when black is out of style except for
Goth kids, who do look kinda kewl ;')

Jim
A pride of lions, a gaggle of geese, a pack of wolves, and a sewer of bankers.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] EXE Problem

2013-06-19 Thread Alan Gauld

On 19/06/13 17:41, Jim Mooney wrote:


you should use forward slashes. I have no idea why Bill Gates thought
backslashes were kewl


Because MS DOS was copying CP/M which didn't have directory paths
(it was used with 180K floppy disks that stored everything at the top
level) but did have command options that were indicated by a
forward slash

DIR /S

was a sorted directory listing etc.

So MS DOS inherited / as an options marker which precluded
it's later use as a path separator...


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Alan Gauld

On 19/06/13 18:43, Jim Mooney wrote:

Here's a peeve of mine about Python help - it often has zero examples.


Remember the help text is being generated from the inline doc strings in 
the code so it depends on what people include in their docstrings.
Also it is intended to be concise because you should only be using it at 
the >>> prompt where you can easily type in your own examples and see 
how it works.


The detailed documentation is (or should be) in the online docs.


concept. I'm coming from Jquery, which is chock full of examples,


but JQuery doesn't have an interpreter prompt so you can experiment 
easily like Python (I think I may have seen someones implementation

of a test prompt for JQ but I may be hallucinating!)

The Python >>> prompt is not an afterthought, it's been a fundamental 
part of the Python learning/discovery process since day one. It is 
similar in that respect to the workspace in Smalltalk where arbitrary 
bits of code can be evaluated and tested. You are expected to experiment.



I think the name is confusing zip with compacting, too.


Not sure what you mean by that. It zips two collections together
like a zip fastener. It's got nothing to do with Winzip etc.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Alan Gauld

On 19/06/13 22:01, Jim Mooney wrote:


endless websites that have gone with the new black-is-back style of
spidery gray text on a medium gray background that only Superman could
see.


I second that, I find an increasing number of web sites unreadable
with my ageing eyes because they use shades of the same colour.
The contrast is simply too low.

And why credit card designers insist on using silver lettering
against a white (or light grey) background defeats me - I've
been reduced to shining lights at an angle to generate
shadows with one of my cards.

Let's return to contrasting shades and colours for legibility
please...

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Devin Jeanpierre
On Wed, Jun 19, 2013 at 1:43 PM, Jim Mooney  wrote:
> Here's a peeve of mine about Python help - it often has zero examples.
> I printed help(zip) to see what it does and got this:
>
--snip--
>
> Not understandable right off, IMHO, unless you're already hardcore.

help() is outright harmful to people that don't already know what
they're doing -- it omits things like advice to do with security,
including neglecting to declare that functions are not safe and can
execute arbitrary Python code, that sort of thing, but also the more
common case of just minor security "footnotes" that are nonetheless
important for every user to know.

Definitely use the HTML docs.

-- Devin
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Jim Mooney
On 19 June 2013 16:12, Alan Gauld  wrote:

>
> I second that, I find an increasing number of web sites unreadable
> with my ageing eyes because they use shades of the same colour.
> The contrast is simply too low.

The strange thing is, every good, recent webmastering book has this
big push for Usability, which I would assume includes visibility - but
it appears to be totally forgotten in the lust for gray on gray to
look kewl ;')

Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Jim Mooney
On 19 June 2013 16:08, Alan Gauld  wrote:

> Remember the help text is being generated from the inline doc strings in the
> code so it depends on what people include in their docstrings.
> Also it is intended to be concise because you should only be using it at the
 prompt where you can easily type in your own examples and see how it
> works.
>
> The detailed documentation is (or should be) in the online docs.

True - I have now installed the real html, which is highly visible and
easier, into pyscripter, with hotkeys, and I'll delete that awful chm
help with its tiny font. Now I have Full help for 3.3 and 2.7 a hotkey
away - I can even see 2.7 and 3.3 help side by side in the browser, to
see differences ;')  I have a slow and sometimes intermittent
connection, so I like things installed.

My thought, though, is that since Python is often a first language,
have two-tier help - offer a learner help Lhelp(), that omits the
__garbola__ and uses the space saved for simple examples. With a
proviso on top to go to real help or the docs once you get past the
elementary phase. Just a thought. Or encourage docstring writers that
an example now and then is Not in bad taste ;')

JIm
A pride of lions, a gaggle of geese, a pack of wolves, a sewer of bankers.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel

On 06/19/2013 06:58 PM, Alan Gauld wrote:

On 19/06/13 17:41, Jim Mooney wrote:


you should use forward slashes. I have no idea why Bill Gates thought
backslashes were kewl


Because MS DOS was copying CP/M which didn't have directory paths
(it was used with 180K floppy disks that stored everything at the top
level) but did have command options that were indicated by a
forward slash

DIR /S

was a sorted directory listing etc.

So MS DOS inherited / as an options marker which precluded
it's later use as a path separator...




MSDOS 2, which introduced subdirectories, also had a function to change 
the "switch character".  You could change it to "-" for example, and use 
"/" for a subdirectory delimiter.  But most programs (including many of 
Microsoft's own) ignored the feature, The operating system itself always 
supported both "/" and "\", but not some utilities like maybe DIR.


Also in those days, the head of the MSDOS architecture considered 
himself in competition with the head of XENIX (Unix) architecture.  So 
he resisted things that might have helped compatibility.


--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] EXE Problem

2013-06-19 Thread Dave Angel

On 06/19/2013 06:58 PM, Alan Gauld wrote:

On 19/06/13 17:41, Jim Mooney wrote:


you should use forward slashes. I have no idea why Bill Gates thought
backslashes were kewl


Because MS DOS was copying CP/M which didn't have directory paths
(it was used with 180K floppy disks that stored everything at the top
level) but did have command options that were indicated by a
forward slash

DIR /S

was a sorted directory listing etc.



This is straining my memory of Windows, but I think /S meant 
"subdirectory" so a listing will include subdirectories of the specified 
starting point.


The /od switch would sort by date, (I think), and the /P switch would 
paginate the output (like the earliest primitive forms of 'more').



--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] sound implementation problems

2013-06-19 Thread Steven D'Aprano

Hi Jessica,


On 17/06/13 20:00, jessica peters wrote:
[snip a bunch of stuff]



Traceback (most recent call last):
   File "Horsemen_soundtest.py", line 5, in (module)
 snd = pygame.mixer.Sound("bach-cello-suite-1.wav")
pygame.error: Unknown WAVE data format: 0x4x
C:\Documents and settings\jessica howe\Desktop\GAME DESIGN\JA HOWE GAMES\WIP gam
es\FOUR HORSEMEN)



Although .wav files are relatively simple, there are slight differences in the 
internal format. It may be that pygame has restrictions on what sort of WAVs it 
can play.

If you run Linux, you can try calling:

file bach-cello-suite-1.wav


from the Linux command prompt to get further information about the file, such 
as whether it is stereo or mono, the bit rate, etc. If you are using Windows, 
which I see you are, I can do this for you, if you give me a URL where I can 
download that specific WAV file. You say you downloaded it from 
http://www.freestockmusic.com/ if you can provide the exact page you got it 
from, I will grab the file and give you the details.

Then you can ask the pygame people if there are restrictions on the types of 
WAV files it can play.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Opinion - help could use more examples

2013-06-19 Thread Steven D'Aprano

On 20/06/13 10:21, Devin Jeanpierre wrote:

On Wed, Jun 19, 2013 at 1:43 PM, Jim Mooney  wrote:

Here's a peeve of mine about Python help - it often has zero examples.
I printed help(zip) to see what it does and got this:


--snip--


Not understandable right off, IMHO, unless you're already hardcore.


help() is outright harmful to people that don't already know what
they're doing -- it omits things like advice to do with security,
including neglecting to declare that functions are not safe and can
execute arbitrary Python code,


*blink*

The help documentation is not aimed at people who are such utter beginners to 
programming that they don't know that calling a function calls the function and 
therefore executes code. Documentation always assumes *some* background 
knowledge. Even if you start your documentation with:

"The computer is the machine with a screen on your desk. Plug it into the wall 
socket, turn the power on, then turn the computer on by pushing the On/Off switch."

it still assumes that the reader knows what a screen is, a desk, the wall 
socket, etc. You can't explain *everything*, where would you start?

I think it is perfectly acceptable for the Python documentation to assume that 
anyone reading it will understand that calling a function executes code.


--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need Help Modifying a wxPython GUI (scrolling display and logging)

2013-06-19 Thread Matt D

> A common way to trigger UI actions is a button whose callback calls that.
> Or you can bind in an event hook for closing the window.
> 
> in __init__ add this line - 
> self.Bind(wx.EVT_CLOSE, self.onExit)
> 
> 
> def onExit(self, event):
>'''Run when closing'''
>self.logfile.close()
>self.Destroy() # Continue closing the app otherwise 
>   # you will not be able to close it via UI
> 
> 
> Although, exiting the program will probably close the file for you
> 
> 
> If you are using append mode ('a') you can just do the following
> which will append and close the file for you. 
> with open(filename, 'a' ) as logfile:
> logfile.write( data_string )
> 
> 
> Make sure you add a newline ('\n') to what you write otherwise all 
> your output will be on one line with no spaces
> 
> for x in xrange(15):
> with open( filename, 'a' ) as f:
> f.write( str(x) )
> 
> filename=
> 01234567891011121314
> =
> 
Hey thanks,
Currently my data is written like this:
2013-06-19
10:09:53,Unknown,(0x270),Plain,HDU,0x265932377fd55dd000,00x1,Standard
MFID (pre-2001),0x666a,
2013-06-19
10:34:43,Unknown,(0x270),Plain,HDU,0xb616ddc0dc3f7d6c00,0xfff,Standard
MFID (pre-2001),0x666a,

And so on and so on, the new line is only at the end of the '0x666a' in
the logfile but here the indentation is forced by my email formatting.
so this is good for now.  Thanks for the help.

But I need to be able to open a text file of choice to write the logfile
to. so now i put a button on my panel with the following:

btn = wx.Button(self, -1, "Click me")
sizer.Add(btn, pos=(7,2))

For some reason i cant not for the life of me figure out how to bind the
click event to wxFileDialog.  Like if i try:

btn.Bind(wx.EVT_BUTTON, self.openfile)

I get the AttributeError: object has no attribute 'openfile'

Or if i put something like:

  def openfile(self, event):
dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "",
"*.*", wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
   path = dlg.GetPath()
   mypath = os.path.basename(path)
   self.SetStatusText("You selected: %s" % mypath)
  dlg.Destroy()

or anything like it the whole layout of the panel gets destroyed.
I have been looking for examples and readying the
http://zetcode.com/wxpython/events/ and reading many others but i am
having lots of trouble grasping this.  The examples are always in a
'wxFrame' or part of an 'app' so the differences from mine (wxPanel)
confuse me.
THanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor