Re: [Tutor] newbie to gui programming

2010-07-06 Thread Eric Hamiter
If you decide to run with wxPython there is a pretty handy video series you
could watch:

http://showmedo.com/videotutorials/series?name=PythonWxPythonBeginnersSeries

Eric


On Tue, Jul 6, 2010 at 1:48 PM, Alan Gauld wrote:

> "Payal"  wrote
>
>  gui programming? There seems to be many ways to do gui programming in
>> Python namely wxpython, tkinter, gtk, qt etc. Which is the easiest
>>
>
> There are many toolkits but these have as many similarities as differences.
> But none of them will be easy to learn if you have not done GUI work
> before because GUI programming is a whole new style and that's what
> takes the time. Once you learn one framework picking up another is
> not that hard - just a lot of new API names to learn!
>
>
>  nice looking one and works on both windows and Linux?
>>
>
> Nowadays they are all acceptable looking but wxPython would
> be my recommendation, mainly for its support for printing, which
> sounds easy but in Guis is surprisingly difficult. wxPython makes
> it about as easy as it can be.
>
> Don't underestimate the learning curve and use the toolset as much
> as possible, also look at things like plotting libraries if you need to
> display graphs etc.
>
> You can compare very simple GUIs in Tkinter and wxPython
> in the GUI topic of my tutor, and a slightly more complex
> GUI in the Case Study topic.
>
> HTH,
>
> --
> Alan Gauld
> 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
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Request for help learning the right way to deal with lists in lists

2010-07-12 Thread Eric Hamiter
I'm fairly new to programming and Python as well, but I have a suggestion
that may be worth looking into-- are you familiar with pickling? It sounds
like something that may fit in well with what you're trying to do.

Good reference article:

http://articles.techrepublic.com.com/5100-10878_11-1052190.html


On Mon, Jul 12, 2010 at 5:19 PM, Siren Saren  wrote:

> I'm still fairly new to programming.  Python is my first language and I am
> teaching myself as best I can.  I'm struggling with a situation that I
> expect must come up all the time.  I can come up with relatively complicated
> solutions but I wonder if there's not a more pythonic way of doing it.
>
> I've seen a lot of examples in books for dealing with lists of alternating
> data types, but what about a list that doesn't follow a simple numeric
> pattern?  For example, say I have a list that's a composite of two elements:
> books and key pages / albums and favorite tracks / medicines and times
> taken, whatever.  To make a program that does something to the first set of
> elements based on the second set of elements, what kind of structure should
> I set up?
>
> Probably easier to choose one of these.  So pretend I have a list like
> this:
>
> (Crime and punishment, page 10, page 40, page 30, Brother's Karamazov, page
> 22, page 55, page 9000, Father's and Sons, page 100, Anna Karenina, page 1,
> page 2, page 4, page 7, page 9)
>
> Since I can identify the elements and since I know the values are 'in
> order,' in other words the page numbers between the first and second book
> all belong to the first book, I can make a mapping.  But I've been surprised
> at the complexity.  So in this hypothetical, with a regular expression, I
> can easily convert the pages to integers, and identify the two lists.  But
> what's the right way to map them to each other, if I am planning to, for
> example, tear out these key pages and make a wall hanging.  (I would never
> do this with precious books like these, of course).  Am I right to think
> that I want to get them into a form that clearly relates them to each other
> from the outset?  Does a dictionary make sense-- I've read that I should
> expect to put a lot of my data into dictionaries?
>
> My tentative approach has been as follows:
>
> a. Make a sublist of the Books.  Here we could just get the non-integers so
> Books = ('C and P', 'Brothers K' ...)
> b. Look each up book in the main list to get an index values
> c.  Now my approach becomes ugly.  In pseudo code-
>
> For book in Books:
> A dictionary should map the book to a list of all the elements in the
> main list that fall between the book's index value and the next book's index
> value
>
> I keep coming up with embedded loops to express this but I simultaneously
> feel like I am missing a third layer (somehow maybe it's 'for book,' 'for
> index,' 'for element'?) and like Occham is going to come by with his razor
> and laugh at me and say, "oh there's a function that does this called the
> "one to many mapping function."
>
> I think I'm reading the right books and going to the right web pages and
> such to learn, but in this case, I must have just not comprehended.  Would
> be grateful for any input.  Have enjoyed reading the archives of this group
> as I've been trying to get my head around programming.  Thanks again
>
> Soren
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Eric Hamiter
Hi all,

New programmer here. This is what I want to do:

1. Open an existing text file named "grocery_list.txt", which has one
item per line, like so:

butter
juice
bread
asparagus
magazines
ice cream

2. ...and search for these items in a pre-defined list.

But I can't seem to get this working. Right now after trying the following:


aisle_one = ["chips", "bread", "pretzels", "magazines"]

grocery_list = open("grocery_list.txt", "r")
for line in grocery_list.readlines():
if line in aisle_one:
   print "success"
else:
   print "no joy"
grocery_list.close()


I get this:

no joy
no joy
no joy
no joy
no joy
no joy

when I'm expecting this:

no joy
no joy
success
no joy
success
no joy


Am I close? This seems like it should work but I'm obviously missing something.

Thanks,

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


Re: [Tutor] Searching a text file's contents and comparing them to a list

2010-07-14 Thread Eric Hamiter
Fantastic! I have this, which now works. Is there a better place to put
string.strip?

aisle_one = ["chips", "bread", "pretzels", "magazines"]

grocery_list = open("grocery_list.txt", "r")
for line in grocery_list.readlines():
if line.strip() in aisle_one:
   print "success! i found %s" % line
else:
   print "no joy matching %s" % line
grocery_list.close()


Thanks Emile.


On Wed, Jul 14, 2010 at 11:02 AM, Emile van Sebille  wrote:


> Try adding some debugging code here, maybe changing the print to:
>  print "no joy matching %s" % line
>
> Then read up on readlines and string.strip.
>
> HTH,
>
> Emile
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Searching a text file's contents and comparing them toa list

2010-07-14 Thread Eric Hamiter
On Wed, Jul 14, 2010 at 12:26 PM, Alan Gauld wrote:

>
> If you never need a stripped version of line again, or if you
> are planning on writing it out to another file then this is fine.
> If you are going to use it again its probably better to strip()
> and asign to itelf:
>
> line = line.strip()
>
> Also you might find rstrip() slightly safer if you have any
> unusual characters at the start of line...
>

Thanks for the tip Alan, I think I'll assign it to itself.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Searching a text file's contents and comparing them toa list

2010-07-14 Thread Eric Hamiter
Follow-up question: My code is now this:

aisle_one = ["chips", "bread", "pretzels", "magazines"]
aisle_two = ["juice", "ice cream"]
aisle_three = ["asparagus"]

def find_groceries():
grocery_list = open("grocery_list.txt", "r")
for line in grocery_list.readlines():
line = line.strip()
if line in aisle_one:
first_run = "%s" % line + " - aisle one.\n"
elif line in aisle_two:
second_run = "%s" % line + " - aisle two.\n"
elif line in aisle_three:
third_run = "%s" % line + " - aisle three.\n"
else:
out_of_luck = "%s" % line
print first_run, second_run, third_run
print "I couldn't find any %s. Add it to the database. \n" % out_of_luck
grocery_list.close()

find_groceries()


I can see that the variables first_run, second_run and third_run are
writing over themselves while looping, which is logical, but this is
not what I want. If I simply print them immediately instead of storing
them as variables, all items will print, but not in the order I wish.
The ultimate goal of the program will be to sort the items based on
aisle locations. Is there an efficient way to do this?

I think I want some kind of incremental counter going on in the loop
to prevent them from overwriting themselves, or a way to store
multiple variables, but I'm not sure how to do that.

Thanks for any ideas. This list and all its participants are super
helpful-- I'm very appreciative.

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


Re: [Tutor] Searching a text file's contents and comparing them toalist

2010-07-14 Thread Eric Hamiter
Thanks for the pointers! This is now working, albeit probably ugly and clunky:


aisle_one = ["chips", "bread", "pretzels", "magazines"]
aisle_two = ["juice", "ice cream"]
aisle_three = ["asparagus"]

def find_groceries():
with open("grocery_list.txt") as grocery_list:

first_trip = ["Located on aisle 1: "]
second_trip = ["Located on aisle 2: "]
third_trip = ["Located on aisle 3: "]
no_trip = ["Not found in the database: "]

for item in grocery_list:
item = item.rstrip()
if item in aisle_one:
first_trip.append(item)
elif item in aisle_two:
second_trip.append(item)
elif item in aisle_three:
third_trip.append(item)
else:
no_trip.append(item)

sorted_list = first_trip, second_trip, third_trip, no_trip
print sorted_list

find_groceries()


Last question (for today, at least): Right now, the output is less
than aesthetically pleasing:

(['Located on aisle 1: ', 'bread', 'magazines'], ['Located on aisle 2:
', 'juice', 'ice cream'], ['Located on aisle 3: ', 'asparagus'], ['Not
found in the database: ', 'butter', 'soap'])

How can I format it so it looks more like this:

Located on aisle 1:
bread
magazines

Located on aisle 2
[etc...]


I tried putting "\n" into it but it just prints the literal string.
I'm sure it has to do with the list format of holding multiple items,
but so far haven't found a way to break them apart.

Thanks,

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


Re: [Tutor] Python Book recomandation!

2010-07-15 Thread Eric Hamiter
Hi Daniel,

As a fellow complete beginner, I have actually started a web site that
details just this. I'm learning as I go and have tried to put together
a curriculum of sorts that will helpfully guide other newbies as well,
and reinforce what I'm learning for myself.

http://letslearnpython.com/

Pardon my own plug, but you are exactly the audience member I am
targeting. Everything I recommend with the exception of a paperback
book is free to access. I'm adding more "lessons" as I go, and
hopefully as I progress, I can make more specific recommendations.

You are off to a great start by asking this list; I've found the
people here are very friendly and extremely knowledgeable.

Thanks,

Eric


On Thu, Jul 15, 2010 at 4:07 PM, Daniel  wrote:
> Hello, I recently browsed the BeginnersGuide/NonProgrammers section of the
> Python website, but I have a question regarding it. With what book I should
> start learning Python? Or should I take them in the order they are presented
> there on the website?I have no previous programming experience, thanks.
>
>
>
> Have a great day!
>
> ___
> Tutor maillist  -  tu...@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
Not sure if this is the right place for this, since this is a tutor list,
but I think it is because it involves learning Python and the application of
knowledge.

I've just started learning it as my initial programming language as of two
months ago. I like to think I'm making steady progress, and I now understand
the most rudimentary level of the basics. What I keep reading is how Python
is most powerful on server side applications, in the cloud, so to speak. The
portability of Python is also widely evangelized.

Here's my problem with this so far-- I can write a basic script, have it
take in data, rearrange it, and spit it back out. Following along in a book,
I can write a basic GUI or game. It's all wine and roses on my Windows
laptop, where I have everything configured just right, with all of the
modules in place where they need to be.

Moving this to a server or even another computer so far has been a seemingly
impossible task. There's a lot of documentation for CGI scripting (which is
now frowned upon, with every page recommending looking into wsgi), and there
have been applications devoted to transforming scripts into Windows
executables (py2exe, etc.) but it seems like this is much more confusing
than need be, and I can't get them to work regardless. When I try and google
for solutions, choosing any terms like "web" or "server" point me to massive
framework solutions like Django or Pylons, which seem extraordinarily
complex for what I want.

Specific examples: I have a livewires/pygame GUI game I wrote along with
folowing the book "Python Programming for the Absolute Beginner" and it
works great on my laptop. I tried installing Python/pygame on a work
computer and copying my scripts over, but it endlessly fails with errors so
obtuse I can't troubleshoot. I'm not even sure if I have the correct modules
installed here. Should they be under "Lib" or "libs" or "includes"?  Trying
to use py2exe fails because I can't figure out how to include non-scripts in
the final program, like .pngs or .jpgs. How would I even begin to put this
on a server? I'm clueless.

Another program I am using on my laptop is a convenience script-- it takes
in a text list of groceries, and spits out a formatted list based on aisle
locations so I can get in and out of the grocery store faster. My laptop is
the only place I can use this. I've tried using multiple CGI examples, and
it always results in a "File Not Found" error. Not even sure how I can debug
it. I can have the server do a simple one-line of printing "Hello World" but
anything more complicated than that makes it implode.

The most frustrating thing is how flippantly experienced programmers say to
use Django for Python web apps because it's so simple to use. It took me a
good half-day to just install it, and unless I'm writing a sample code or if
I want to clone a newspaper service, I have absolutely no idea how I would
use it efficiently. I want to learn the basics before running off to learn a
new framework. I'm trying to find good resources so I can continue self
teaching, but everything I find seems to be tailored to two classes: the
complete newbie who doesn't know how to print a line, or an advanced
programmer who is using list comprehension within a recursion with multiple
modules.

In short, is there a "simple" method for putting python scripts onto a
server that I do not host myself? I've seen web2py and it looks like it
would be more my speed, but support is lacking and doesn't seem too
compatible with my host. I use Dreamhost, and they are very adaptable and
configurable, but so far I can't find an easy way to accomplish what I want.

Thanks for reading this far if you did! I welcome any suggestions
whatsoever.

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


Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
>
> Get a linux hosting account, and a web address, most linux hosting
> comes with python, so practice in the 'cloud'.
>

I have that-- an account with Dreamhost. This hasn't solved my problems yet
though. Like I said, I can have it write a simple

Hello, World!

...but if I make it do anything more complex, I get a 404 error. To make my
question more simple-- how does one learn to create web apps with Python? It
seems to be that what it is advertised as, but not at all ready to go "out
of the box" for that type of thing. And that is fine, but I want to learn
how without having to learn a framework like Django-- yet. Or is this just
considered a kind of necessity?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
On Sat, Jul 31, 2010 at 4:48 PM, bob gailer  wrote:

>
>  Please post that code, and the URL you use to invoke it.
>

test.py: this works on my laptop but not on the server

http://pastebin.com/ChjUzLRU

test-working.py: this works on both laptop & server

http://pastebin.com/iLNTrGdW

both available for execution here:

http://erichamiter.com/xkred27/



> Do you import cgi?
>

Yes.


>
> There is a companion module (cgitb) that captures exceptions and returns
> the traceback to the web browser.
>

I tried that as well. I'm sure I'm missing something fundamental here, but
that's kind of obvious since I posted I don't know what I'm doing in the
first place! :)

Thanks,

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


Re: [Tutor] Writing scripts and apps for Internet consumption

2010-07-31 Thread Eric Hamiter
On Sat, Jul 31, 2010 at 9:53 PM, bob gailer  wrote:

>
> Main difference I see is lack of any html tags in test.py! Try adding
>
>1. print ""
> 2. print "Publix Aide"
> 3. print ""
> 4. # the store map print statements go here
> 5. print ""
>
> I understand that this would work-- my question was how can I get a python
script to "do anything" on it? Why is it returning a 404 error?


> Where is erichamiter.com/  hosted? Is
> there a way I could put something there?
>
>
A hosted server, so it's not on my local machine. Afraid I can't hand you
any access directly to it, I have too much personal stuff on there at the
moment. I would be more than happy to look at any code you would want to
send in an email or pastebin, and I could put it up for a test.

Thanks,

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


Re: [Tutor] web-based python?

2010-08-01 Thread Eric Hamiter
On Sun, Aug 1, 2010 at 1:56 PM, Che M  wrote:

> For a long time I have hoped for a "Python web apps for absolute beginners"
> tutorial that doesn't assume any knowledge.  For a beginner, it is not even
> clear what a "web frameworks" is let alone which one he/she should start
> with or if it is even needed.
>
> I understand much of this is about web apps generally and is not germane
> only to Python, but it would be good if a Python tutorial at least pointed
> toward
> this information, since for many beginners, the entry portal to anything is
> through
> Python.  To just refer someone to Django when they don't know the first
> thing about
> web apps is, I think, off-putting.
>
> Che
>
> Che, my sentinments exactly. I'm looking for something similar.

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


Re: [Tutor] Formatting date/time

2010-08-04 Thread Eric Hamiter
There are a few solutions here:

http://stackoverflow.com/questions/904928/python-strftime-date-decimal-remove-0

Eric


On Wed, Aug 4, 2010 at 1:30 PM, Eduardo Vieira wrote:

> I'm trying this example from python docs:
> from time import gmtime, strftime
> strftime("%a, %d %b %Y %H:%M:%S +", gmtime())
>
> Output = 'Wed, 04 Aug 2010 17:58:42 +'
> Is not there a string formatting option for the day without a leading
> zero? Like: 'Wed, 4 Aug 2010 17:58:42 +'
>
> It looks like it's not in the docs.
>
> Thanks
>
> Eduardo
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-06 Thread Eric Hamiter
Your ideas are intriguing to me, and I wish to subscribe to your newsletter.

Eric


On Fri, Aug 6, 2010 at 11:19 AM, Ian Ozsvald  wrote:

> Hi all. I'm a long time Pythonista and co-founder of
> http://ShowMeDo.com/ (and author of 140 of the Python tutorials
> there), I'm here with an idea...
>
> Recently I've started to follow a couple of email lists that send me
> regular tip emails, I've found them to be rather nice - an easy to
> read tip that comes every week that I can digest when I'm ready and I
> can reference afterwards.
>
> I don't recall ever coming across a Python Learners tip series in this
> format and I'm guessing it would be well received. Could I get some
> feedback please?
>
> I've already planned a set of 10 weekly tips (each about 5 paragraphs
> of text plus code examples) covering a bunch of things that are useful
> for a new Python programmer. Some are about the 'right' way to write
> Python code, some introduce neat modules (like Excel, web scraping,
> processes), some show you how to do complex stuff (like 3D, web
> servers and faster mathematics) in just a few lines of Python.
>
> It would also be quite nice to wrap up some of the oft-asked Python
> Tutor questions into the tips (I always meant to create some ShowMeDo
> videos covering these problems but never had the time :-( ).
>
> Before proceeding I'd like to do a sanity check - has anyone done this
> already? I'd hate to re-invent the wheel!
>
> Assuming it hasn't been done - would *you* choose to subscribe to the
> list (it would be free, just an email, nothing complex and no
> spam/sillyness)? Just say 'yes' if so, that way I know there's an
> audience.
>
> If the interest is good then I'll extend the series of 10 and
> introduce some guest authors into the mix.
>
> Any takers?
> Ian.
>
> --
> Ian Ozsvald (A.I. researcher, screencaster)
> i...@ianozsvald.com
>
> http://IanOzsvald.com
> http://MorConsulting.com/
> http://blog.AICookbook.com/
> http://TheScreencastingHandbook.com
> http://FivePoundApp.com/
> http://twitter.com/IanOzsvald
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor