Re: [Tutor] Problem with python

2010-10-20 Thread Dave Kuhlman
e('') n3 = Node('') n4 = Node('') n5 = Node('eeee', [n1, n2]) n6 = Node('', [n3, n4]) n7 = Node('', [n5, n6]) n7.show(0) print '=' * 20 shownode(n7, 0) test() #

Re: [Tutor] Hiding Superclass Methods

2010-10-11 Thread Dave Kuhlman
> inheritance. It's a good technique. And, it's called delegation. For more on delegation, see this: http://en.wikipedia.org/wiki/Delegation_(programming) Also see Alan's message in this same thread. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] Ide To use? Other extras to install?

2010-10-11 Thread Dave Kuhlman
ee the recent thread on IDEs. Here is a comparison of Python IDEs: http://www.infoworld.com/d/developer-world/infoworld-review-nine-fine-python-development-tools-374 This is a multi-page article. The subsequence pages give some details about each IDE. - Dave -- Dave Kuhlman http://www.rexx.com

Re: [Tutor] What's the catch with ZopeDB?

2010-06-11 Thread Dave Kuhlman
it on top of several different relational database engines, for example, PostgreSQL, MySQL, sqlite3, etc. See: http://docs.djangoproject.com/en/1.2/#the-model-layer http://www.djangobook.com/en/2.0/chapter05/ - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___

Re: [Tutor] Looking for duplicates within a list

2010-06-11 Thread Dave Kuhlman
o o See http://docs.python.org/library/functions.html#enumerate - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Extract from file

2010-06-09 Thread Dave Kuhlman
ally, if you are sure that there are no commas inside of quotes in your input data. However, it seems that you are dealing with a CSV (comma separated values) file. Python has a module for that. See: http://docs.python.org/library/csv.html That module might help you write safer code. --

Re: [Tutor] Bowing out

2010-03-05 Thread Dave Kuhlman
re your ability and knowledge about Python. And, I appreciate the huge amount of effort you've put into helping us. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] saving output data in a file

2009-12-04 Thread Dave Kuhlman
> -- > --prasad mehendale > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Easy Problem

2009-09-01 Thread Dave Kuhlman
ight want to know about the textwrap module in the standard library: http://docs.python.org/library/textwrap.html#module-textwrap - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] python interpreter vs bat file

2009-07-19 Thread Dave Kuhlman
sked several times for more information. You really need to read: http://catb.org/~esr/faqs/smart-questions.html There are people on this list who are very generous with their time. It's a valuable resource. Please don't waste it. I don't mean to be rude. But, you will help

Re: [Tutor] python workspace

2009-06-06 Thread Dave Kuhlman
org/ It will show you local variables. But, remember that these are the local variables at *run-time*. They are names to which values have been bound at that point in the execution of your code. And, as Alan pointed out elsewhere in this thread, the variable has no type. It's the value (w

Re: [Tutor] Iterating through a function list

2009-05-20 Thread Dave Kuhlman
if name in funcs: funcs[name](arg, ...) Python is making this too easy for you, making it hard to spot the solution. Think of parentheses as a "function call operator", which you can apply to any callable value. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___

[Tutor] Yet another Python book

2009-04-10 Thread Dave Kuhlman
can get it at no cost, in various formats here: http://www.rexx.com/~dkuhlman/#a-python-book And, if you really do feel a need to kill a tree, you can purchase a copy on paper here: http://www.lulu.com/content/paperback-book/a-python-book/2599081 - Dave -- Dave Kuhlman http

Re: [Tutor] text editor and debugger for python

2009-03-24 Thread Dave Kuhlman
t Jed, emacs, Kate, Joe, ... They are all installable on Ubuntu Debian GNU/Linux. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Paython as a career

2009-03-17 Thread Dave Kuhlman
ber of times to teach classes in corporations that had a need for Python skills. So, there are definitely companies out there that would view Python programming skills as valuable. I suspect that there are others on this list who also teach Python in a corporate setting. - Dave -- Dave Kuhlm

Re: [Tutor] Issues Parsing XML

2009-03-12 Thread Dave Kuhlman
rth it. You can learn about lxml here: http://codespeak.net/lxml/ - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Graph theory

2008-12-04 Thread Dave Kuhlman
hon.org/doc/essays/graphs/ > > Also googling "python graph" finds many alternatives. And, if you are also interested in the visual display of graphs, then look for graphviz and python-pygraphviz. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] Python Working Environment, Checkout, Compare (diff), ...

2008-10-13 Thread Dave Kuhlman
.dll) and not an emulation layer like that provided by Cygwin tools." - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] List indexing problem

2008-07-26 Thread Dave Kuhlman
In [27]: IP Out[27]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] In [28]: id(IP[0]) Out[28]: 13122016 In [29]: id(IP[1]) Out[29]: 13121152 In [30]: id(IP[2]) Out[30]: 13121800 - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] where to report a bug?

2008-07-25 Thread Dave Kuhlman
27;ve written code with that bug myself. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Online class/education for Python?

2008-07-21 Thread Dave Kuhlman
o do it on your own, also take a look at: http://wiki.python.org/moin/BeginnersGuide http://wiki.python.org/moin/BeginnersGuide/NonProgrammers http://wiki.python.org/moin/BeginnersGuide/Programmers - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] Create file and input text

2008-06-29 Thread Dave Kuhlman
ust your users. They can over-write files. In a real application, you might want to do some checking on the file before opening it. Consider using something like this: if os.path.exists(filename): print 'Warning. File %s exists.' % filename else:

Re: [Tutor] listing classes

2008-05-20 Thread Dave Kuhlman
print inner_classes if __name__ == '__main__': test() Which prints out: [('A', )] [('B', ), ('C', ), ('__class__', )] - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] Buffering in file.read()

2008-05-12 Thread Dave Kuhlman
Kent Johnson tds.net> writes: > > Footnote 2.3 says, "Specifying a buffer size currently has no effect > on systems that don't have setvbuf(). The interface to specify the > buffer size is not done using a method that calls setvbuf(), because > that may dump core when called after any I/O has be

Re: [Tutor] Buffering in file.read()

2008-05-08 Thread Dave Kuhlman
ault, which is usually line buffered for tty devices and fully buffered for other files. If omitted, the system default is used." -- http://docs.python.org/lib/built-in-funcs.html#l2h-54 Looks to me that the buffering is done for you, but that you can control

Re: [Tutor] Debug C library in python program

2008-04-28 Thread Dave Kuhlman
" http://www.delorie.com/gnu/docs/gdb/gdb_191.html Hope this helps. It has been quite a while since I've done this, but I remember that it worked pretty slick. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman #!/bin/sh -v gdb -d /path/to/your/source/code -x test2.gdb python `ps

Re: [Tutor] Question about global variables on modules

2008-04-07 Thread Dave Kuhlman
print t3() test() See http://docs.python.org/ref/global.html. Note that to *get* (not set) the value of a global variable from within a function, you do not need to use the global statement. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman _

Re: [Tutor] Which Python Script Editor of Choice?

2008-04-03 Thread Dave Kuhlman
his page will give you more choices than you want: http://en.wikipedia.org/wiki/Comparison_of_text_editors My favorites are: - Jed - Emacs - SciTE - Jedit (but only if you have lots of memory) Jed, Emacs, and SciTE are scriptable. SciTe, perhaps, is not. - Dave -- Dave Kuhlman http://www.rexx.com/~dk

Re: [Tutor] Using split with a backslash

2008-04-02 Thread Dave Kuhlman
27;) See http://docs.python.org/ref/strings.html Another example: In [1]: a = 'abc\\def\\ghi' In [2]: len(a) Out[2]: 11 In [3]: a.split('\') File "", line 1 a.split(

Re: [Tutor] append string

2008-03-22 Thread Dave Kuhlman
then follow Andreas's suggestion to use list append followed by string join. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] CSV file processing...

2008-03-20 Thread Dave Kuhlman
27;, 'Rating', 'Lemon', 'Bright yellow and tart', '5', 'Eggplant', 'Purple and shiny', '6', 'Tangerine', 'Succulent', '8'] Then process *that* list.

Re: [Tutor] How do I destroy class instances ?

2008-02-24 Thread Dave Kuhlman
ances, then when your instances go away (are garbage collected), those other things will also automatically go away, too. No extra work is needed. It takes a little thought before you will figure out that this is something that needs (almost) no thought. Hope this helps. - Dave -- Dav

Re: [Tutor] designing POOP

2008-02-10 Thread Dave Kuhlman
racted from: http://dirtsimple.org/2004/12/python-is-not-java.html Maybe I'm "old school", but I still use getters and setters for access from outside the class and direct access from within methods in the class. - Dave [some good arguments snipped] -- Dave Kuhlman

Re: [Tutor] if ... else shorthand form ?

2008-02-09 Thread Dave Kuhlman
hot_interval']:0 For this specific task, if I understand it correctly, there is an easy and Pythonic idiom: self.snap_init[i] = items.get('snapshot_interval', 0) See: http://docs.python.org/lib/typesmapping.html For mappings/dictionaries: a.get(k[, x]) is equivalent

Re: [Tutor] Document Control System

2008-01-14 Thread Dave Kuhlman
, in contrast with content management might mean something slightly different to you. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Mobile Python

2007-12-31 Thread Dave Kuhlman
60 http://sourceforge.net/projects/pys60/ There is an emulator, so you can test some of your code without even loading it onto a cell phone device. This sounds like exciting stuff. Please keep us informed about your progress. - Dave -- Dave

Re: [Tutor] Learning about callbaks

2007-12-29 Thread Dave Kuhlman
perator" (parentheses). Here is a trivial example: def f1(x): print 'f1: %s' % x def f2(x): print 'f2: %s' % x def use_them(funcs): for func in funcs: func('abcd') def test(): funcs = [f1, f2]

Re: [Tutor] Using 'join ' function to create a string

2007-12-21 Thread Dave Kuhlman
;s problem, you could also try map() and a lambda: ', '.join(map(lambda x,y: '%s:%s' % (x, y, ), X, Y)) Or, maybe unrolling it makes it more readable: In [31]: fn = lambda x,y: '%s:%s' % (x, y, ) In [32]: ', '.join(map(fn, a, b)) Out[32]: '

Re: [Tutor] constants, flags or whatever

2007-12-19 Thread Dave Kuhlman
thing that looks a bit like an enum. If so, here is a Python idiom for enums: Mode_none, Mode_moving, Mode_inserting, Mode_jumping = range(4) action = Mode_moving if action == Mode_jumping: o o o - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___

Re: [Tutor] Indentation Issue and Blind People

2007-12-02 Thread Dave Kuhlman
ode distribution. In particular, these may be of interest: reindent.py and tabify.py. And, for those who feel that they must have some marker at the end of a block (in addition to an "out-dent"), look at Tools/scripts/pindent.py. Dave --

Re: [Tutor] Python CMS advice wanted

2007-11-27 Thread Dave Kuhlman
//zope.org/ And, I do not know anything about this one, but it looks interesting -- Skeletonz: http://orangoo.com/skeletonz/ You might also find helpful info at: http://www.cmsreview.com/ If you have success with one, please report back here with your experience, suggestions, etc. Dave -- Dave Kuhlman ht

Re: [Tutor] adding a new folder to Python's importable modules search path

2007-11-26 Thread Dave Kuhlman
ot notation). See: http://docs.python.org/ref/import.html (and search for __init__) Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ElementTree - reading large XML files as file handles

2007-11-21 Thread Dave Kuhlman
s: http://www.prescod.net/python/pulldom.html http://www.ibm.com/developerworks/xml/library/x-tipulldom.html http://www.idealliance.org/papers/dx_xml03/papers/06-02-03/06-02-03.html http://www.idealliance.org/papers/dx_xml03/papers/06-02-03/06-02-03.html#pull Hope this helps. Dave --

Re: [Tutor] visualizing code structure / flow charting

2007-11-06 Thread Dave Kuhlman
ttp://wiki.python.org/moin/IntegratedDevelopmentEnvironments Two that I've looked at: - Geany -- http://geany.uvena.de/ - Eric -- http://www.die-offenbachs.de/eric/index.html -- Eric was easy to install on Debian GNU/Linux, but may be more of a

Re: [Tutor] question re type()

2007-10-27 Thread Dave Kuhlman
port types if type(n) is types.IntType Or, is this a frivolous question that makes no difference? Dave > > Alan G. > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- D

Re: [Tutor] calling a variable name

2007-10-23 Thread Dave Kuhlman
like me, is it sort of like saying that the costs are averaged out over a sequence of appends? Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Complexity of list operations

2007-10-23 Thread Dave Kuhlman
for example: lst.insert(0, obj) and: obj = lst.pop() Also, this is probably a good place to mention deque (http://docs.python.org/lib/deque-objects.html), which attempts to reduce those costs. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman __

Re: [Tutor] Variables in workspace

2007-10-13 Thread Dave Kuhlman
for. However, as your mother might say: That's what's good for you. Also, remember, in Python, global variables are just entries in the dictionary returned by globals(), anyway. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] slice lists and slicing syntax questions

2007-10-13 Thread Dave Kuhlman
d = c[2,5,6,8] print 'd:', d e = c[2] print 'e:', e test() Which prints out: d: [10, 25, 30, 40] e: 10 Was that what you wanted? Notice that "c[2,5,6,8]" results in passing a tuple to __getitem__, because it is the comm

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Dave Kuhlman
ex is a Python-like language for writing Python C extensions in a Python-like language. Pyrex/Cython gets you much closer to C code than Python. Question: Someday will all the Python built-ins be implemented in Cython/Pyrex. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman

Re: [Tutor] using **kwargs in __init__() as attributes

2007-10-01 Thread Dave Kuhlman
k at the "exec" command (http://docs.python.org/ref/exec.html). But, that's a dangerous way to code. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Image Analysis

2007-09-11 Thread Dave Kuhlman
nk you. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] parsing response from SOAPpy request

2007-09-01 Thread Dave Kuhlman
s to those requests, but it does not (directly) generate or parse XML. SOAPpy does that for you. You have most likely already looked at those examples. So, maybe there is something that I don't understand about your question? Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Variable scope for class?

2007-08-30 Thread Dave Kuhlman
a class does not create an enclosing scope. Actually, the particular edition of Alan's book that I have is old enough so that it does not discuss the Enclosing namespace, which came later to Python. The enclosing namespace not make a difference in your example, but does in mine. Dave --

Re: [Tutor] user in put

2007-08-27 Thread Dave Kuhlman
: 'peaches, nectarines, cantaloupe' Note that we append each food to a list, then do string.join(). That's faster than doing multiple string concatenations. In this case there are not enough strings to make a difference. But, it's a good hab

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Dave Kuhlman
as to create the values when asked for them) except when a very large range is used on a memory-starved machine or when all of the range's elements are never used (such as when the loop is usually terminated with break). http://docs.python.org/lib/built-in-funcs.html#l2h-80

Re: [Tutor] iterate list items as lvalue

2007-08-20 Thread Dave Kuhlman
gt;>> for idx, item in enumerate(array): array[idx] = item * 2 >>> array [2, 4, 6, 8, 10] >>> array2 [2, 4, 6, 8, 10] Basically, this modifies the list "in place", rather than making a new list from the old one. Dave -- Dave Kuhlman

Re: [Tutor] open multiple files

2007-08-15 Thread Dave Kuhlman
('*.txt') for name in names: infile = open(name, 'r') etc. etc infile.close() Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] global question

2007-08-11 Thread Dave Kuhlman
8 inte = 11 agl = 14 # etc ## # outside1.py import globals def whatever(): x = globals.stre # etc ###### Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] send os.system() output to tarfile?

2007-08-07 Thread Dave Kuhlman
stdout and stderr. tarfile will enable you to stuff that captured output into a tar.gz file. Also, see the zipfile module if you want to save into a zip file. With tarfile, you may have to write data to a temp file and then archive that. With zipfile, you can write content directly

Re: [Tutor] Books with exercises and problems to solve

2007-08-07 Thread Dave Kuhlman
ctivestate.com/ASPN/Cookbook/Python/ Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Editors .. which do you reccomend for a amateur?

2007-08-04 Thread Dave Kuhlman
ns well and has built-in debugging support. http://www.die-offenbachs.de/eric/index.html Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Which GUI?

2007-08-02 Thread Dave Kuhlman
_ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] passing form data into a class

2007-07-31 Thread Dave Kuhlman
r__(self, name): if name in self.vardict: return self.vardict[name] else: raise AttributeError, 'Bunch has no attribute: %s' % name def test(): d = {'aaa': 111, 'bbb': 222, } b = Bunch(d) print b.aaa

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Dave Kuhlman
On Thu, Jul 26, 2007 at 01:48:44PM -0600, Eric Brunson wrote: > > Do other interpreters work? > > Try: > > #!/usr/bin/perl > print "Perl Sucks!!!\n"; > > or: Or, try: #!/usr/bin/env python Dave -- Dave

Re: [Tutor] function declaration problems perhaps?

2007-07-25 Thread Dave Kuhlman
B(object): pass By the way, this is an important and fundamental subject about Python. When I teach classes on Python, I always need to explain Python's execution model, and I always struggle with it. So, anything you can tell me that would

Re: [Tutor] Here is newbie doc on how to implement generators

2007-07-23 Thread Dave Kuhlman
On Mon, Jul 16, 2007 at 06:13:35PM -0400, Kent Johnson wrote: Kent - Rather than try to reply in detail to your suggestions, I've tried to ammend my document to reflect your comments. Thanks again for the help. Dave [good suggestions and corrections from Kent, snipped] -- Dave Kuhlman

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-22 Thread Dave Kuhlman
gle window. For more on screen, do "man screen" and look here: http://en.wikipedia.org/wiki/GNU_Screen Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Dave Kuhlman
ib/re-syntax.html http://docs.python.org/lib/node46.html Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] scrips

2007-07-20 Thread Dave Kuhlman
listed? If not, you will need to find your script. 3. If your script is not in the current directory, either (1) change to the directory containing the script with the "cd" command or (2) use the full path to the script, as in: python c:\some\path\to\myscript.py Hope

Re: [Tutor] Here is newbie doc on how to implement generators

2007-07-13 Thread Dave Kuhlman
On Fri, Jul 13, 2007 at 12:39:40PM +1200, John Fouhy wrote: > On 13/07/07, Dave Kuhlman <[EMAIL PROTECTED]> wrote: > > And, I have a question -- If you look at the example of the > > iterative (non-recursive) generator (the Doubler class), you will > > see that it walks

[Tutor] Here is newbie doc on how to implement generators

2007-07-12 Thread Dave Kuhlman
rs, please give me a link. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question regarding syntax

2007-07-11 Thread Dave Kuhlman
fter the "%" character. The mapping key selects the value to be formatted from the mapping. For example: >>> print '%(language)s has %(#)03d quote types.' % \ {'language': "Python", "#": 2} Pytho

Re: [Tutor] Module imports

2007-07-11 Thread Dave Kuhlman
ur life." haha It is not that you should "try not to worry". It's that you are doing things the way you are intended to. And, you are probably in sync with the cosmos, too. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Code query..works in IDLE but not DrPython editor

2007-07-10 Thread Dave Kuhlman
hat DrPython is finding a different module random from that which Idle finds. I was tripped by a similar error. Idle and IPython both have my bin directory on sys.path (I'm on Linux), while standard Python does not. IPython was finding one of my modules in the bin directory, whereas standard

Re: [Tutor] file methods

2007-07-10 Thread Dave Kuhlman
mode, less data than what was requested may be returned, even if no size parameter was given. IPython is at: http://ipython.scipy.org/moin/ Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] backslashes

2007-07-08 Thread Dave Kuhlman
en(s1) Out[3]: 9 In [4]: s1.replace('\\', '') Out[4]: 'abcdefg' Notice the length of the string (before removing the backslashes). Each apparently double backslash actually has a length of 1. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___

Re: [Tutor] Importing and creation on the fly

2007-06-26 Thread Dave Kuhlman
gave me > an error when I did the eval(actionStmt). Could anybody shed some light on > this? Thanks in advance. For the task of importing, look at the "imp" module: http://docs.python.org/lib/module-imp.html Also, the "inspect" module may be of help: http://d

Re: [Tutor] Fastest way to iterate through a file

2007-06-26 Thread Dave Kuhlman
speed is important, then you might try a solution that uses a regular expression in place of for id in idList: if id in line: A regular expression of the form "(id1|id2|id2)", which you could construct programmatically, might work for your problem: import re s1 =

Re: [Tutor] Parsing text file

2007-05-14 Thread Dave Kuhlman
to have in your tool bag. And, like I said above: It's fun. Besides, if your problem becomes more complex, and, for example, the input is not quite so line oriented, you will need a more powerful approach. Wikipedia has a better explanation than mine plus an example and links: http://en.wikipedi

Re: [Tutor] Making table

2007-03-19 Thread Dave Kuhlman
advance. Try ljust and rjust. They are string functions/methods and are described here: http://docs.python.org/lib/string-methods.html Something like the following might work for you: In [1]: value = 3.45678 In [2]: ("%0.3f" % value).rjust(10) Out[2]: ' 3.457'

Re: [Tutor] skipping ahead within a loop

2007-03-15 Thread Dave Kuhlman
, but sometimes it helps to understand what is going on underneath, because the for statement and iterators are very general, powerful, and elegant features of Python. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] how to send command line args to py script

2007-03-11 Thread Dave Kuhlman
standard library. optparse is newer and more powerful than getopt, but also seems a bit more complex. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Embedding Python

2007-02-26 Thread Dave Kuhlman
On Sun, Feb 25, 2007 at 01:35:52PM -0800, Dj Gilcrease wrote: > On 2/25/07, Dave Kuhlman <[EMAIL PROTECTED]> wrote: > > If you have not already, you will want to look at SWIG > > (http://www.swig.org/). SWIG will generate C or C++ code from a > > header file contain

Re: [Tutor] Embedding Python

2007-02-25 Thread Dave Kuhlman
or popen.popenx (x = 2,3, 4). See http://docs.python.org/lib/module-popen2.html. I'l let others on the list comment on whether this is dangerous. I suppose if all the code (that is compiled by SWIG) is under your control or if you trust your users, it might not be too dangerous. Dave --

Re: [Tutor] Main program confusion

2007-02-19 Thread Dave Kuhlman
in order to execute that sample code. Once you have found the run module, ... Step 2 -- Read the source in the run module. In particular, you are looking for a function named main. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Replying to the tutor-list

2007-02-18 Thread Dave Kuhlman
procmail filter doesn't seem to pick up the list when it's cced. > But that's for me to sort out it :) Maybe a procmail rule something like this: :0: * ^(To|Cc):[EMAIL PROTECTED] tutor-python-folder Note the Cc. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing class attributes: use methods only?

2007-02-14 Thread Dave Kuhlman
ious; ...). I mean we are programmers, after all." OK. OK. Maybe I had too much coffee this morning. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Replying to the tutor-list

2007-02-14 Thread Dave Kuhlman
e on. I just checked. It looks like when I use the reply-to-list operation in mutt, the only recipient is [EMAIL PROTECTED] Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python for Sysadmins

2007-02-13 Thread Dave Kuhlman
eed to cover and help with covering them, too. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] CRC calculation with python

2007-02-06 Thread Dave Kuhlman
ause at least a compilation warning. > > This looks like a snippet, not a complete CCITT CRC calculation. Also, see the crcmod module: http://crcmod.sourceforge.net/ But, the README that comes with crcmod recommends the md5 module in the Python standard library. Dave -- Dave Kuhlma

Re: [Tutor] How to make ftplib show progress while uploading a large file

2007-02-04 Thread Dave Kuhlman
it for wxPython. But, at least it gives you some scaffolding to start with. Note the "fancy" flag and variable, which is probably what you want, not too sure. Hope this helps. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman #!/usr/bin/env python import sys, os import ftplib import getopt

Re: [Tutor] site-packages and permissions to byte-compile

2007-01-29 Thread Dave Kuhlman
dules in a directory in which you *do* have write access and then add that directory to your PYTHONPATH. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Best IDE for Python

2007-01-25 Thread Dave Kuhlman
rg/)? There is a plug-in for Python. But, on my machine, the last time I looked, it was buggy and incredibly slow. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Perfect Python web stack?

2007-01-17 Thread Dave Kuhlman
seInterfaces http://www.python.org/doc/topics/database/ http://www.python.org/doc/topics/database/modules/ http://www.sqlalchemy.org/ http://www.sqlobject.org/ Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] possible import locations

2007-01-17 Thread Dave Kuhlman
in your current directory, where it would only affect programs run from that directory. Which is recommended and when? Also, the .pth file thing seems to be a way to give a package, when it is installed, to hijack the import path by stuffing paths abov

Re: [Tutor] Array indexing

2007-01-16 Thread Dave Kuhlman
are more than one statement on a line. And writing more than one statement on a line is usually discouraged anyway. > The "fix" I'm currently using is to write the index I want: > > (directoryTable[0], directoryTable[1]) Or, if you need an index variable: directoryTable[i], directoryTable[i+1]) Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question about ConfigParser

2007-01-06 Thread Dave Kuhlman
note the restriction to string values in the docs on the set method: set(section, option, value) If the given section exists, set the given option to the specified value; otherwise raise NoSectionError. While it is possible to use RawConfigParser (or ConfigParser with raw parameters set to true) for internal storage of non-string values, full functionality (including interpolation and output to files) can only be achieved using string values. New in version 1.6. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Opening a pdf on a certain page

2006-12-12 Thread Dave Kuhlman
use evince (on Linux) to read PDF docs. When I open a document the second time, evince automatically shows the last page I was viewing when I previously closed evince. And, the following command: $ evince -p 12 somedocument.pdf will open that document to page 12.

Re: [Tutor] Is there any good turtorial about numeric python for beginners?

2006-12-06 Thread Dave Kuhlman
On Wed, Dec 06, 2006 at 05:49:22PM -0800, linda.s wrote: > Is there any good tutorial about numeric python for beginners? > I have googled around and many of them are either too old or aims at > experienced users... Look here: http://new.scipy.org/Wiki/Documentation Dave -- Dav

  1   2   >