Re: [Tutor] Using Python with a Mac

2010-02-23 Thread Eric Dorsey
Not sure if this is what you're asking, but you can invoke the Python
interpreter from the command line (Terminal)

Open a new terminal, and at the $ prompt just type "python"..

$ python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print "now in the python interpreter"
now in the python interpreter

To run a python program from the command line (assuming its in the same
directory), just type:

$ python myprogram.py



On Sun, Feb 21, 2010 at 10:06 AM, Marco Rompré wrote:

> Hi everyone, I would like to know how to use python with a mac.
>
> For now, I go to spotlight, open terminal then type IDLE and a window pops
> up but its like the window that opens when you run your programs already
> saved and I'm not able to open another window to write a script from
> scratch.
>
> Could someone help me please please
>
> I have the latest Macbook Pro so 2,88ghz 15 inches screen.
>
> Thank you in advance
>
> Marchoes
>
> ___
> 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] What Editori?

2010-02-23 Thread Eric Dorsey
On any platform, I use (gui) vim (gvim on Win/Linux, mvim/macvim on OSX)
with this plugin:

http://www.vim.org/scripts/script.php?script_id=30



On Tue, Feb 23, 2010 at 5:40 PM, Benno Lang wrote:

> On 24 February 2010 01:24, Giorgio  wrote:
> > what text-editor do you use for python?
>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] An interesting situation befalls me

2010-05-11 Thread Eric Dorsey
> On Sat, May 8, 2010 at 5:31 PM, Kirk Z Bailey wrote:
>>
>>> An instructor of mine is about to teach the FIRST EVER class in Python at
>>> Saint Petersburg College; knowing I am a snakecharmer, he asked me for
>>> referrals to online resources.
>>>
>>> Oh my.
>>>
>>
>
> Here is another resource, the Byte of Python book:

http://www.swaroopch.com/notes/Python_en:Table_of_Contents

The online version is free, or you can buy the book.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDLE vs PythonWin

2009-02-09 Thread Eric Dorsey
You can call a .py script from the command line, and it will run there. So,
in Windows XP: Start > Run > type "CMD"
Vista: Start > type "CMD" into the Start Search field.
If you're in Linux, get to a Terminal.
In Windows another window will open with something
like...C:\FolderWithMyPyFile>
Linux something like m...@ubuntu-desktop:~$

Assuming "uberprogram.py" is in the current folder, you can then just type
into the command prompt like C:\FolderWithMyPyFile>uberprogram 

You can see the results of the program right in the command prompt/terminal
window.

On Mon, Feb 9, 2009 at 6:09 PM, Wayne Watson
wrote:

>  You must be up 24/7!
> When I open a py file with pythonwin, it brings up the dialog and in its
> window, there are two windows. One is called interactive window (IW), and
> the other (script window--SW) contains the program py code. To execute it, I
> press the little running icon or F5 and two printed lines appear, as they
> should, in the IW. If I remove the SW, how do I run it in another "editor",
> vi, vim, emacs, notebook, ... whatever, and see the output in the IW?
>
> ALAN GAULD wrote:
>
>  > Yes, but how do you debug the code interactively when you have
> > the editor outside pythonwin? Do you copy it into the pythonwin editor?
>
> Do you mean using the Python debugger?
> If I need to do that I will either use the command line debugger (pdb)
> inside the shell window or close the vim session and start pythonwin
> (or Eclipse which has a really good debugger!) But in 10 years of using
> Python I've only resorted to the debugger maybe a dozen times in total.
> Usually a few print statements and a session with the >>> prompt is
> adequate to find any bugs. The best debugging tools are your eyes!
>
> Remember too that you can always import the module into the shell
> window if you need to test specific functions in isolation.
>
> Alan G.
>
>
> ALAN GAULD wrote:
>
> The point wasn't about vim per se - that just
> happens to be my favourite editor - but really
> about the way of working with 3 separate windows.
>
> Really it was just to show that you don't necessarily
> need to use an all-in-one IDE like Pythonwin or IDLE,
>
>
>
> --
>
>Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>  (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
>
>  *The Richard Feynman Problem-Solving Algorithm:*
> *  (1) write down the problem;*
> *  (2) think very hard;*
> *  (3) write down the answer.***
>  **
>
> **Web Page: 
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-11 Thread Eric Dorsey
>>> config_names = {'start_time': '18:00:00', 'gray_scale': True, 'long':
120.0}

>>> config_names
{'start_time': '18:00:00', 'gray_scale': True, 'long': 120.0}
>>> for i, x in config_names.items():
... print i, x
...
start_time 18:00:00
gray_scale True
long 120.0
>>>

On Wed, Feb 11, 2009 at 7:48 PM, Wayne Watson
wrote:

>  I have a dictionary that looks like:
>
> config_names = {"start_time : '18:00:00', 'gray_scale' : True, "long":
> 120.00}
>
> If I iterate over it, the entries will appear in any order, as opposed to
> what I see above. However, in the config file, I'd like to keep them in the
> order above. That I want to write the config file in order. Perhaps, I need
> a list like c_names = ["start_time", "gray_scale", "long"] to get the keys
> out in the order I need? Maybe there's another way?
> --
>
>Wayne Watson (Watson Adventures, Prop., Nevada City, CA)
>
>  (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)
>
>  *The Richard Feynman Problem-Solving Algorithm:*
> *  (1) write down the problem;*
> *  (2) think very hard;*
> *  (3) write down the answer.***
>  **
>
> **Web Page: 
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Keeping Dictonary Entries Ordered

2009-02-12 Thread Eric Dorsey
 But you need to have an order that will work with sorted().
> Its not just the order you add items to the dict. To store an
> arbitrary order I suspect you would need to maintain a
> secondary list with the keys in the order of insertion.
> The most reliable way to dop that would be to subclass
> dict. Somebody may already have done that so its worth
> a google...
>
> HTH,
>

Alan, can you give a short snippet of what that would look like?  I was
trying to code out some idea of how you'd retain insertion order using
another dict or a list and didn't get anywhere.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu

2009-02-16 Thread Eric Dorsey
Greetings Tutor:
I've managed to install Python 2.6 on my Ubuntu VM from source, however, it
looks as though I missed something important along the way. My 2.6
interpreter does not have readline support (example: I cant hit up arrow to
repeat the last command) Is there a way to add this functionality now?

Or alternative, if I just rebuild it, does anyone know the flag or verbage
to get readline support in?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu

2009-02-18 Thread Eric Dorsey
I did an aptitute install of  ibreadline5-dev and then did ./configure and
make again, and still don't have any functionality to be able to hit
up-arrow and get a command repeated while inside the interpreter. Any ideas?


On Tue, Feb 17, 2009 at 7:24 PM, Lie Ryan  wrote:

> On Mon, 16 Feb 2009 22:34:23 -0700, Eric Dorsey wrote:
>
> > Greetings Tutor:
> > I've managed to install Python 2.6 on my Ubuntu VM from source, however,
> > it looks as though I missed something important along the way. My 2.6
> > interpreter does not have readline support (example: I cant hit up arrow
> > to repeat the last command) Is there a way to add this functionality
> > now?
>
> WORKSFORME
> I have Ubuntu and python2.6 and the up arrow history works fine.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu

2009-02-19 Thread Eric Dorsey
Still doesnt work.. I just get this when I hit the up arrow:>>> ^[[A

Bah. It works in the 2.5 version that came packaged with it. Thanks for
trying :)

On Wed, Feb 18, 2009 at 11:27 PM, زياد بن عبدالعزيز الباتلي <
ziyad.alba...@gmail.com> wrote:

> On Wed, 18 Feb 2009 20:19:56 -0700
> Eric Dorsey  wrote:
> > I did an aptitute install of  ibreadline5-dev and then
> > did ./configure and make again, and still don't have any
> > functionality to be able to hit up-arrow and get a command repeated
> > while inside the interpreter. Any ideas?
> >
> >
> I don't know what's wrong, Python should pickup "libreadline" and use
> it automatically if it was installed.
>
> Try passing "--with-readline" to the "configure" script.
>
> If that doesn't help, then I'm sorry, I'm out of ideas.
>
> Hope that help.
> Ziyad.
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Add readline capabilities to a Python build 2.6 on Ubuntu

2009-02-25 Thread Eric Dorsey
Thanks for all your continued insights on this. I'm going to investigate the
.configure log, as well as look around at other readline packages.. But,
noob question, did you just go into something like synaptic to find out what
readline type packages are installed? (Sorry if this is annoying anyone on
the list, but its all in the name of getting the Python inerpreter to be
happy !) Or did you do some kind of command line aptitude "list out readine
stuff"?

On Wed, Feb 25, 2009 at 10:01 PM, Lie Ryan  wrote:

> On Thu, 19 Feb 2009 09:27:34 +0300, زياد بن عبدالعزيز الباتلي wrote:
>
> > On Wed, 18 Feb 2009 20:19:56 -0700
> > Eric Dorsey  wrote:
> >> I did an aptitute install of  ibreadline5-dev and then did ./configure
> >> and make again, and still don't have any functionality to be able to
> >> hit up-arrow and get a command repeated while inside the interpreter.
> >> Any ideas?
> >>
> >>
> > I don't know what's wrong, Python should pickup "libreadline" and use it
> > automatically if it was installed.
> >
> > Try passing "--with-readline" to the "configure" script.
> >
> > If that doesn't help, then I'm sorry, I'm out of ideas.
> >
>
> Try installing other readline modules that looks suspicious. In my Ubuntu
> machine (these are all readline-related modules in my machine, not only
> the ones that is needed for python), I have these packages installed:
> v   lib32readline-dev-
> v   libghc6-readline-dev -
> v   libghc6-readline-doc -
> v   libghc6-readline-prof-
> v   libreadline-dbg  -
> v   libreadline-dev  -
> i   libreadline5 - GNU readline and history libraries, run-ti
> i A libreadline5-dev - GNU readline and history libraries, develo
> i   readline-common  - GNU readline and history libraries, common
>
> try matching that and ./configure then make.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Add elements to list and display it [Very newbie question]

2009-02-27 Thread Eric Dorsey
Here is one possible implementation of your project.

*Code:*
#Dont use list as a variable name, its one of the reserved words.
mylist = []

#realize any values captured here are strings
x = raw_input('Enter num or text: ')
mylist.append(x)
x = raw_input('Enter num or text: ')
mylist.append(x)

#output the type of objects you've entered (hint: they'll always be
strings.. ;)
print type(mylist[0])
print type(mylist[1])

#print the list of items
for i in mylist:
print i

*When you run the program:*
Enter num or text: 27
Enter num or text: Eric


27
Eric


On Fri, Feb 27, 2009 at 10:19 AM, Network Administrator <
administrador.de@gmail.com> wrote:

> I am beggining to learn Python and I appreciate if you help me with this:
>
> "I want a piece of a program to request the user to input "elements"
> (numbers, text, etc) and store them into a list. Then, I want to display all
> the elements one-per-line."
>
> I started using this code:
>
> #!/usr/bin/env python
> #
> # This function fills any given list
> # and display its content.
> #
> x = 0   # Variable "x" initiallized to zero, just
> because Python required it
> while (x != 't2' ): # On user's input "t2", no more input must be
> required
> list = []# I start a zero-elements list
> x = raw_input('Enter your number or text: ')# Software
> asks for user's input.
>
> list.append(x)
> # User's input is append to the list "list"
>
> for x in list:  # It asks to enter the list and...
> print x  # print their elements.
>
> Unfortunately, this code fails to do what I expect. I notice that user's
> input is not being append to the list, so, when I require to print the
> elements of the list only "t2" is displayed. I don't know how to append
> elements to a list on user's input.
>
> I appreciate your clearence.
>
> Regards,
>
>
> Will.
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 61, Issue 3

2009-03-01 Thread Eric Dorsey
Not sure if this is what you mean, but:
Say you have the files efunc.py and trytry.py in the same folder.

*The content of efunc.py is:*
def funky():
print 'funkytown'

*The content of trytry.py is:*
import efunc

efunc.funky()

*Output would be:*
n...@ububox:~$ python trytry.py
funkytown
n...@ububox:~$

trtry.py "easily and automatically" uses the code from efunc.py It calls the
function funky(). Granted this is a prety silly example, but is that what
you mean by using code written by someone else? You do this with modules all
the time, like import os, import glob, etc. Any .py file imported into
another .py file is a module, granted most of them are a bit more useful
than efunc.py


> I'm sorry, I've realized I didn't explain my needs at all.
> I was a little influenced by drupal's definition of modules, which is
> completely different from python's.
> With module here I meant plug-in or extension: a piece of code written
> by someone else that can be easily (and automaticallly) integrated
> into my program.
> My program must provide the posibility to be extended without editing
> its code, just like mozilla's add-ons.
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Convert XML codes to "normal" text?

2009-03-03 Thread Eric Dorsey
*So here is my program, I'm pulling some information off of my Snipt feed ..
*

import feedparser

d = feedparser.parse('http://snipt.net/dorseye/feed')

x=0
for i in d['entries']:
print d['entries'][x].title
print d['entries'][x].summary
print
x+=1

*Output*

Explode / Implode List
>>> V = list(V)
>>> V
['s', 'p', 'a', 'm', 'm', 'y']
>>> V = ''.join(V)
>>> V
'spammy'
>>>

I know, for example, that the > code means >, but what I don't know is
how to convert it in all my data to show properly? In all the feedparser
examples it just smoothly has the output correct (like in one the data was
whatever and it had the special characters just fine.) I didn't
notice any special call on their feedparser.parse() and I can't seem to find
anything in the feedparser documentation that addresses this. Has anyone run
into this before? Thanks!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert XML codes to "normal" text?

2009-03-04 Thread Eric Dorsey
Senthil,

That worked like a charm, thank you for the help! Now my Snipt's are
actually legible :)


On Wed, Mar 4, 2009 at 12:01 AM, Senthil Kumaran wrote:

> On Wed, Mar 4, 2009 at 11:13 AM, Eric Dorsey  wrote:
> > I know, for example, that the > code means >, but what I don't know is
> > how to convert it in all my data to show properly? I
>
> Feedparser returns the output in html only so except html tags and
> entities in the output.
> What you want is to Unescape HTML entities (
> http://effbot.org/zone/re-sub.htm#unescape-html )
>
> import feedparser
> import re, htmlentitydefs
>
> def unescape(text):
>def fixup(m):
>text = m.group(0)
>if text[:2] == "&#":
># character reference
>try:
>if text[:3] == "&#x":
>return unichr(int(text[3:-1], 16))
>else:
>return unichr(int(text[2:-1]))
>except ValueError:
>pass
>else:
># named entity
>try:
>text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
>except KeyError:
>pass
>return text # leave as is
>return re.sub("&#?\w+;", fixup, text)
>
>
> d = feedparser.parse('http://snipt.net/dorseye/feed')
>
> x=0
> for i in d['entries']:
> print unescape(d['entries'][x].title)
>print unescape(d['entries'][x].summary)
>print
>x+=1
>
>
>
> HTH,
> Senthil
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Trouble understanding modifying parent class..

2009-04-13 Thread Eric Dorsey
Hi tutors, I am studying classes a bit, and am having trouble with this
concept and would appreciate your help!


class A:
def __init__(self, name, value=1):
self.name = name
self.value = value

And now I want a subclass, one that overrides the value=1 and defaults to
value=2, how do I code that? I'm understanding subclasses that have
different methods that have different behavior, but I'm having trouble doing
this.

Do we have to call the __init__ of the parent somehow? Is it "replaced" or
overridden in an __init__ method of the subclass?

.. or stated simply:
If you have class A: which has def __init__(self, name, value=1), how do you
code a subclass B(A): that automatically starts with value=2?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to run a .py file or load a module?

2009-04-26 Thread Eric Dorsey
Dayo,
I modified the code a little bit to make things work the way I think you
meant it to work(hopefully), and I changed the name of the function so that
its' not the same name as the python file itself, but hopefully this answers
your questions. Here is my countdown.py

def launchme(n):
while n > 0:
print n
n -= 1
else:
print 'Blastoff!'

#uncomment to run from the shell
#launchme(7)

So, assuming we're running the interpreter from the same folder that
countdown.py is in. You have to call module.function(parameter)

>>> import countdown
>>> countdown.launchme(4)
4
3
2
1
Blastoff!
>>>

If we uncomment the "#launchme(7)" line, and run it from the shell:

$ python countdown.py

7
6
5
4
3
2
1
Blastoff!




On Sun, Apr 26, 2009 at 3:35 PM, Dayo Adewunmi wrote:

> I'm looking at recursion in "Think Python", and this is the bit of code:
>
>
> #!/usr/bin/env python
>
> def countdown(n):
>   if n <= 0:
>   print 'Blastoff!'
>   else: print n
>   countdown(n-1)
>
>
> I've typed that in vim and saved as countdown.py, but I'm not sure how to
> run it. I've had other
> python files, where the triggering function didn't take any arguments,
> so I would just put a `foo()` at the end of the .py file.
>
> However with this particular function that requires an argument, I'm not
> sure how to run it. I've had to type it out in the python prompt and then
> call
> the function with an argument. That works, naturally.
>
> I've also tried this:
>
>   >>>import countdown
>   >>>countdown(10)
>
> but this is the error I get:
>
>   Traceback (most recent call last):
> File "", line 1, in 
>   NameError: name 'countdown' is not defined
>
> How can I
>
> a) Open my shell, and do something like: $ python countdown.py   but have
> it take an argument and pass it to the function, and execute.
>
> b) Import the function in the interactive interpreter, and call it like so:
>
>   countdown(10)
>
> without getting the abovementioned error.
> Thanks.
>
> Dayo
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] run command

2009-09-04 Thread Eric Dorsey
Make sure you are in the same directory as your hello.py, then run the
interpreter/shell

Try this:
>>>import hello

then you can do things like:
>>>dir(hello)

and
>>>help(hello)

I'm not sure if that's what you were asking, but "import" is how you ..
import. HTH.




On Fri, Sep 4, 2009 at 5:31 PM, upasara wulung <
upasara.wulung.1...@gmail.com> wrote:

> hello,
>
> Wish you would not mind a really beginner question. I am trying to use
> 'run' command, but didnot success yet. How I did it:
>
> (1) In a certain working folder, I produced simple python file, for an
> example, hello.py, which is free of error.
> (2) I called python from the same working folder using command 'python'
> (3) In the python shell, I executed: >>> run hello.py
>
> But I got only an error message: SyntaxError: invalid syntax.
>
> Please tell me a clue? I did those stuffs in Linux Debian.
>
> Thx a lot
>
> Upa.
> ___
> 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] Simple Game

2009-09-06 Thread Eric Dorsey
Hi Corey,

If this is going to be a command line program, two things that immediately
come to mind for me are: validating user input and persistence. If you put
something like "(1) to attack, (2) to run" what if the user types "yes", or
"Y", or "9"? You'll want to make sure your program doesn't crash on wrong
user input. And as far as "saving" the game, will the user be able to pick
up where they left off(tracking user stats, progress in the game,
posessions, etc)? If so, you'll need some kind of persistence, Pickle-ing or
a SQLite database, etc.


On Sun, Sep 6, 2009 at 10:09 AM, Corey Richardson  wrote:

> So far, I can use tuples/lists/dictionary's, and define some functions, and
> a bit of other things.
> Would it be hard for me to make a simple text rpg game? Or is there
> something else I should know before I try that.
> ___
> 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


[Tutor] Date validation?

2008-11-06 Thread Eric Dorsey
Greetings,I have a program where I ask a user to enter a date in format
-MM-DD, and get a string like: '2008-10-25'

Can anyone tell me how I would verify this is a real date before allowing it
to be passed on to the next part of the program?

-- 
(e)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python - Data Mining?

2009-01-04 Thread Eric Dorsey
Hi Nick,
I don't know about the graphing portion of your question, but yes Python
does interact very well with databases. I have been working on a workout
tracking program the last two months or so, and I'm new to programming. I'd
highly recommend SQLite as a built-in database solution. I know it's
included in Python version 2.5 which is what i'm currently running. You can
call it at the top of your program with "import sqlite3", then you can run
queries and create tables, etc.

Here is some example code of SQLite usage in my program:

#create the database, or connect if it already exists
conn = sqlite3.connect('workoutstats.db')

#create a variable called cursor to use, since its easier than typing out
conn.cursor() all the time..
cursor = conn.cursor()

#create a table
cursor.execute('''
  CREATE TABLE WR (id INTEGER PRIMARY KEY, reps SMALLINT(1000),
  weight SMALLINT(1000), exer VARCHAR(30), date DATE)
  ''')

#query the WR table, feeding it the 'srch' variable which fills in where the
SQL has a ?
cursor.execute(
"SELECT SUM(REPS) FROM WR WHERE EXER=?",
(srch,)
)

-Eric

On Sun, Jan 4, 2009 at 11:25 AM, Nick Scholtes  wrote:

> Hi,
> I'm still very, very new to Python and programming. I was wondering if
> anyone can point me in the right direction.
>
> As I gradually learn Python, one of the things I want to be able to do is
> take a database, run queries and extract information and then graph that
> information visually to see patterns in the data. Where should I start?
> Does Python do this? If not, what language is used for this?
>
> Thank you very much,
> Nick
>
>
> --
> Art: http://www.coroflot.com/bellsoffreedom
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
(e)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 2 & 4 or more spaces per indentation level..

2009-01-15 Thread Eric Dorsey
Dear Pythonistas:

Working in IDLE on Windows Vista, I have one program that I set to have 2
character spacing (due to the levels of if's and while's going on -- later
my brother called this a bit of a code smell, ie. logic shouldn't go that
deep, it should be broken out into separate functions instead. Thoughts on
that are welcome to, do any of you feel logic should only go so many layers
deep?), and my editor defaults to 4 (Which I believe is the standard
according to PEP 8)
I copied some code from the 2 spacing program to another I'm writing
currently which has the default 4, and it got things kind of screwy with
spacing. I believe I've got it fixed now by manually tabbing/spacing, etc.,
but I was wondering, if this happened on a much bigger scale, or you were
say, pasting code in from some example where they used a different spacing
than you, is there a simple/good/smart way to get it all back to the 4
spacing default? Or if for example I wanted to convert my 2 spacing program
to the conventional 4?

- Eric
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Volunteer Opportunities?

2009-01-21 Thread Eric Dorsey
-- 
eric dorsey | www.perfecteyedesign.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Volunteer opportunities

2009-01-21 Thread Eric Dorsey
(My apologies if a blank message comes up first with this heading -- The
first time I meant to type this I managed to tab  accidently to Send and hit
it before even filling out the message.. :/ )
Does anyone know of any good volunteer opportunities for projects that
learning Python coders can work on? Or possibly nonprofits or the like that
need smaller-type applications worked on?

Much thanks!

-- 
eric dorsey | www.perfecteyedesign.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Print question in IDLE

2009-01-30 Thread Eric Dorsey
At the >>> prompt (which is the interactive) interpreter, try:
print('food is very nice')  #lets eat



On Fri, Jan 30, 2009 at 5:45 PM, jims  wrote:

> I apologize for asking such a dumb question but I have no prior programming
> experience and am trying to learn by following examples from a book. And
> also from the web.
>
> Simply put here is where I am stuck. (Python version 3.0)
>
> I type in the example using the comment command:
>
> (example)  *>>> "food is very nice" #lets eat
>
> *(I am supposed to get) *food is very nice
>
> (*What I do get is) SyntaxError:  invalid syntax (,  line 1)
>
> I understand the comment part, no problem but no way can I get past what
> ever else I am doing wrong.  I assume it's something fundamental but I can't
> get past this.
> Thanks for any help.
> Jim
> _______
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
eric dorsey | www.perfecteyedesign.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 2.6.1 + Linux Ubuntu (Gutsy Gibbon)

2009-02-05 Thread Eric Dorsey
I am trying to teach myself Linux, and so I'm running Ubuntu (Gutsy Gibbon)
as a virtual machine. I went to terminal, started up Python and realized it
was version 2.5 so I thought I'd just upgrade to 2.6.1 After doing some
Googling around, it seems that Ubuntu is highly reliant on Python 2.5, so
upgrading isn't so simple after all.
Is this just Ubuntu that is so integrated with Python, or all flavors of
Linux? Doesn't this hinder developers who use Ubuntu (and Linux?) as their
primary OS when new versions of Python come out?

I have been using Windows forever, but everyone says Linux is the
development environment. Thoughts?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor