Re: [Tutor] Programmatically Post to Pastebin

2011-05-10 Thread James Mills
API key. A similar tool I wrote (which pastes to codepad.org) is here: https://bitbucket.org/prologic/tools/src/59d89262e6b1/codepad The approach would be very similar. Feel free to adapt this. cheers James -- -- James Mills -- -- "Problems are

Re: [Tutor] Titles from a web page

2011-05-04 Thread James Mills
into which provides similar functionality. -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Calling a python script using subprocess

2011-04-28 Thread James Mills
thon", "installModule.py", "--mods", "mod1", "mod2", "mod3"], stdout = subprocess.PIPE, stderr = subprocess.STDOUT) cheers James -- -- James Mills -- -- "Problems are solved by method" __

Re: [Tutor] list.__init__ within class definition

2011-04-20 Thread James Mills
data) ... >>> l = Tomato([1, 2, 3]) >>> l [1, 2, 3] >>> Your example: >>> class Tomato(list): ... def __init__(self, data): ... list.__init__(data) ... >>> l = Tomato([1, 2, 3]) >>> l [] >>> Do you see why ? cheers Jame

Re: [Tutor] jenia. cannot install mysqldb

2011-04-20 Thread James Mills
ing a pre-built binary distribution (or a pure python lirbary). Either way, you'll need MySQL install (at the very least mysqlxx.dll or something) cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist -

Re: [Tutor] working with strings in python3

2011-04-18 Thread James Mills
On Tue, Apr 19, 2011 at 10:34 AM, James Mills wrote: > Normally it's considered bad practise to concatenate strings. > Use a a format specifier like this: > >> message = "Bah." >> >> if test: >>   message = "%s %s" (message, " Humbug!

Re: [Tutor] How to handle exceptions raised inside a function?

2010-12-01 Thread James Mills
;install" the package into your site-packages or $PYTHONPATH (if configured that way by means of configuration). NB: Copying the package's directory into site-packages hwoever has the same effect. The directory that contains the __init__.py cheers James -- -- James Mills -- --

Re: [Tutor] List Changing Order

2010-11-25 Thread James Mills
cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] decorators (the "at" sign)?

2010-10-25 Thread James Mills
.. This has a similar form to the code you're studying and registers func with atexit hooks so that when the application terminates, func(...) gets called. Hope this helps, cheers James 1. http://www.python.org/dev/peps/pep-0318/ -- -- James Mil

Re: [Tutor] Networking

2010-10-15 Thread James Mills
/ 2. http://bitbucket.org/prologic/circuits/wiki/Home -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Networking

2010-10-14 Thread James Mills
On Fri, Oct 15, 2010 at 11:22 AM, chris wrote: >> But what if I want it to serve one client, go to another and then go back. >> How does that work? You do some I/O multi-plexing or multi-processing/threading. You might want to do some reading on this. cheers James -- --

Re: [Tutor] creating a class

2010-10-05 Thread James Mills
init__("apple") apple = Apple() print apple.name For more information, I suggest you start reading the python tutorial (1) cheers James 1. http://docs.python.org/tutorial/ -- -- James Mills -- -- "Problems are solved by method" ___

Re: [Tutor] Smart posting - Was: Re: Tutor Digest, Vol 80, Issue 11

2010-10-02 Thread James Mills
and wants to get digests. It's far easier (for me at least) to just get each email as it comes in. --James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or ch

Re: [Tutor] plotting pixels

2010-09-16 Thread James Mills
On Fri, Sep 17, 2010 at 12:13 PM, Bill Allen wrote: > Is there a simple way to plot pixels in Python, without resorting to turtle > graphics? Give matplotlib a go. Alternatively you may want to try pygame or pyglet. cheers James -- -- James Mills -- -- "Problems are solve

Re: [Tutor] constructing objects with one set of required options

2010-09-16 Thread James Mills
self.a = a self.b = b self.c = c self.x = x self.y = kwargs.get("y", None) cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] constructing objects with one set of required options

2010-09-16 Thread James Mills
... def foo(self, a, b, *args, **kwargs): ... There are probably other combinations, but these are probably the most common. The point I'm trying to make here is that this is really "up to you". Use a combination of variable arguments (*args) and maybe some arguments with defaul

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread James Mills
, "copyright", "credits" or "license" for more information. >>> s = "foo\"bar'" >>> s 'foo"bar\'' >>> s.replace("\"", "").replace("'", "") 'foobar&#

Re: [Tutor] If/elif/else when a list is empty

2010-09-13 Thread James Mills
On Tue, Sep 14, 2010 at 2:46 PM, wrote: >    rgenre = re.split(r';', rf.info["genre"]) > KeyError: 'genre' Use something like this: if "genre" in rf.info: rgenre = re.split(..., ...) else: # ... no genre cheers James -- -- Ja

Re: [Tutor] If/elif/else when a list is empty

2010-09-13 Thread James Mills
(rgenre)<1: # I was hoping this would take care of the "there is > no genre information" scenario but it doesn't >    rg1=rg2=rg3="NA" the "else" statement does not expect (nor accept) an expression after it, just write: else: ...

Re: [Tutor] input problem

2010-09-13 Thread James Mills
;..." s = raw_input(prompt) while s: if s == "hello": hello() elif s == "quit": break s = raw_input(prompt) cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] SSH session problems with network devices

2010-08-26 Thread James Mills
Ssh'ing and executing remote commands might be interpreted differently by the Cisco ssh/shell/etc. It might be worth your while looking into this as it'll have nothing at all to do with Python or Paramiko.. cheers James -- -- James Mills -- -

Re: [Tutor] SSH session problems with network devices

2010-08-26 Thread James Mills
" ssh into your Cisco routers and be presented with a shell of some kind ? cheers James PS: Please post to the list. -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change s

Re: [Tutor] SSH session problems with network devices

2010-08-26 Thread James Mills
; commands. What Router is this ? What OS does it run ? I may have some experience with this as I often ssh into various networking devices including Linux servers and systems, etc... cheers James -- -- James Mills -- -- "Problems are solved by method" ___

Re: [Tutor] continuous running of a method

2010-08-22 Thread James Mills
t; from time import time >>> seed(time()) >>> def foo(): ... if 0.5 < random() < 0.6: ... return True ... >>> x = foo() >>> while x is None: ... x = foo() ... >>> x True >>> cheers James -- -- James Mills -- -- "Pro

Re: [Tutor] a graceful program exit

2010-08-11 Thread James Mills
have an entry point and an exit point. main() and SystemExit exception. cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyth

Re: [Tutor] modify csv textfile

2010-08-06 Thread James Mills
), delimiter='|', > quoting=csv.QUOTE_NONE) > for row in reader: >    print row > > > I can print the file, I just need a little help searching and replacing the column 4 data element. Use re.match to match the column. Use csv.writer to write our a new csv file based on the

Re: [Tutor] string to list

2010-08-05 Thread James Mills
On Thu, Aug 5, 2010 at 2:38 PM, Vikram K wrote: > Suppose i have this string: > z = 'AT/CG' > > How do i get this list: > > zlist = ['A','T/C','G'] >>> import re >>> z = 'AT/CG' >>> [x for x in re.s

Re: [Tutor] how to get str() to use my function?

2010-08-04 Thread James Mills
rn "" ... >>> foo = Foo() >>> foo <__main__.Foo object at 0x83d796c> >>> str(foo) '' >>> cheers James -- -- James Mills -- -- "Problems are solved by method" ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
On Fri, Jul 30, 2010 at 12:22 PM, Richard D. Moores wrote: > On Thu, Jul 29, 2010 at 19:10, James Mills > wrote: >> On Fri, Jul 30, 2010 at 11:47 AM, David Hutto wrote: >>> This is basically to get feedback, on a better way to show the >>> greatest common di

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
On Fri, Jul 30, 2010 at 12:10 PM, James Mills wrote: > def gcd(a, b): >    while b != 0: >        (a, b) = (b, a%b) >    return a Here's another solution that uses a generator called factors to generate a list of factors for any given value. The gcd function then uses sets and

Re: [Tutor] A better way for greatest common divisor

2010-07-29 Thread James Mills
er method, or critique of what I've done, let me know. [snip] I have a far simpler solution: >>> from tools import gcd >>> gcd(20, 5) 5 >>> def gcd(a, b): while b != 0: (a, b) = (b, a%b) return a cheers James -

Re: [Tutor] configuring web browser PP3E

2009-01-28 Thread James Mills
On Thu, Jan 29, 2009 at 12:17 PM, bmol...@att.net wrote: > yes, i'm running on Mac OS X / Unix, but i'm afraid i don't know "where" to > change the port to 80. i'm working with the following files straight from > the book 'Programming Python': You're not blind are you ? Because I am. > cgi101.p

Re: [Tutor] configuring web browser PP3E

2009-01-28 Thread James Mills
On Thu, Jan 29, 2009 at 11:31 AM, bmol...@att.net wrote: > Traceback (most recent call last): > File "webserver.py", line 22, in ? >srvrobj = HTTPServer(srvraddr, CGIHTTPRequestHandler) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/SocketServer.py", > line

Re: [Tutor] Having Issues with CMD and the 'python' command

2008-12-15 Thread James Mills
"cmd" has _nothing_ to do with Python. --JamesMills -- -- "Problems are solved by method" On Mon, Dec 15, 2008 at 10:51 PM, Lamonte Harris wrote: > Every time I start cmd on windows it requires me to "set > path=%path%;C:\python26" why? I'm getting annoyed... > > -- > http://mail.python.org/m