Re: [Tutor] Simple CGI script and Apache configuration

2009-02-24 Thread wormwood_3
s/samuelhuckins/ AIM - samushack | Gtalk - samushack | Skype - shuckins From: Martin Walsh To: wormwood_3 Cc: Python Tutorlist Sent: Tuesday, February 24, 2009 2:32:48 AM Subject: Re: [Tutor] Simple CGI script and Apache configuration wormwood_3 wrote:

Re: [Tutor] Simple CGI script and Apache configuration

2009-02-23 Thread wormwood_3
list Sent: Tuesday, February 24, 2009 12:33:35 AM Subject: Re: [Tutor] Simple CGI script and Apache configuration wormwood_3 wrote: > Hello all, Hi Sam, > I'll try to give as much detail as I can, but this is a somewhat vague > problem. I have a very simple script that I would like to i

Re: [Tutor] Simple CGI script and Apache configuration

2009-02-23 Thread wormwood_3
/ AIM - samushack | Gtalk - samushack | Skype - shuckins From: Moos Heintzen To: wormwood_3 Sent: Sunday, February 22, 2009 5:36:32 PM Subject: Re: [Tutor] Simple CGI script and Apache configuration Just noticed that ScriptAlias /python/ &quo

[Tutor] Simple CGI script and Apache configuration

2009-02-22 Thread wormwood_3
Hello all, I'll try to give as much detail as I can, but this is a somewhat vague problem. I have a very simple script that I would like to implement as a CGI script, just so I can hit a URL and get some output. However, after following a number of tutorials, I am still seeing some very odd res

Re: [Tutor] Python & MySQL... Define port.

2009-02-11 Thread wormwood_3
Hello, You can specify the port of the instance you want to connect to simply by passing "port=NUM" in MySQLdb.connect(). Here is a formulation I have found generally useful: import MySQLdb def run_mysql(query, db, user, passwd, port=3306, socket="/var/run/mysqld/mysqld.sock", host="localhost

Re: [Tutor] dict() versus {}

2009-01-21 Thread wormwood_3
or an int as it expects for a keyword argument? Maybe I am missing the use case, so far it just seems strange to force the keyword to a string. -Sam From: bob gailer To: wormwood_3 Cc: Python Tutorlist Sent: Wednesday, January 21, 2009 11:25:12 PM Subj

Re: [Tutor] dict() versus {}

2009-01-21 Thread wormwood_3
hotos - http://www.flickr.com/photos/samuelhuckins/ AIM - samushack | Gtalk - samushack | Skype - shuckins From: bob gailer To: wormwood_3 Cc: Python Tutorlist Sent: Wednesday, January 21, 2009 11:02:35 PM Subject: Re: [Tutor] dict() versus {} wormwood_3 wrote:

[Tutor] dict() versus {}

2009-01-21 Thread wormwood_3
When creating a list of dictionaries through a loop, I ran into a strange issue. I'll let the code talk: >>> l = 'i am a special new list'.split() >>> t = [] >>> for thing in l: ... t.append({thing: 1}) ... >>> t [{'i': 1}, {'am': 1}, {'a': 1}, {'special': 1}, {'new': 1}, {'list': 1}] This

Re: [Tutor] Ip address

2009-01-19 Thread wormwood_3
Hello, This is definitely possible. It's more a matter of system and OS configuration than Python though, so you might want to check out some Linux forums ( http://www.linuxforums.org/ ) for additional help. In short, I think the simplest would be: Have 3 separate network interfaces in your phy

Re: [Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
http://samuelhuckins.com Tech blog - http://dancingpenguinsoflight.com/ Photos - http://www.flickr.com/photos/samuelhuckins/ AIM - samushack | Gtalk - samushack | Skype - shuckins From: Kent Johnson To: wormwood_3 Cc: Python Tutorlist Sent: Monday, Janua

Re: [Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
A small correction to my code, although the point was hopefully still clear: if options.user: do_mysql_query(options.user) else: do_mysql_query() From: wormwood_3 To: Python Tutorlist Sent: Monday, January 12, 2009 4:39:30 PM Subject: [Tutor

[Tutor] Optional parameter passing

2009-01-12 Thread wormwood_3
Hello all, I have used *args and **kwargs to have a function accept optional parameters, but is there a lazy way to optionally pass parameters? For example, say my script can accept a number of parameters for a database connection, such as user, password, and database name. The function that ma

Re: [Tutor] Getting multi-line input from user

2009-01-07 Thread wormwood_3
Joining with newline works perfectly. Thanks everyone! ___ Samuel Huckins Homepage - http://samuelhuckins.com Tech blog - http://dancingpenguinsoflight.com/ Photos - http://www.flickr.com/photos/samuelhuckins/ AIM - samushack | Gtalk - samushack | Skype - shuckins

Re: [Tutor] Getting multi-line input from user

2009-01-06 Thread wormwood_3
>>> For starters you can simplify things a lot: >>> >>> user_input = [] >>> entry = raw_input("Enter text, 'done' on its own line to quit: \n") >>> while entry != "done": >>>user_input.append(entry) >>>entry = raw_input("") >>> user_input = ' '.join(user_input) >>> print user_input >>> >>

[Tutor] Getting multi-line input from user

2009-01-06 Thread wormwood_3
Hello everyone, I'd like to prompt the user for input and get back multiple lines, for example if someone wanted to enter a few paragraphs. Then I'd like to be able to print their input out and preserve formatting. Here's what I have so far: control = True user_input = [] while control: if

[Tutor] Documentation and top matter

2009-01-04 Thread wormwood_3
While PEP 8 and PEP 257 provide ample helpful information on the recommended ways to document classes, functions, and comments within code, I am having a hard time finding recommendations on how to document scripts by way of top matter. For example, I used this format for a while: #!/usr/bin/en

Re: [Tutor] Python - Data Mining?

2009-01-04 Thread wormwood_3
I have done some data analysis work with Python, mostly with MySQL databases. Just as easy as the examples Eric mentioned with SQLite. All depends on what database you have to work with. Did you have any in mind or just wondering about data mining and Python in general? Regarding graphing, I ha

Re: [Tutor] Printing the code of a function

2008-12-28 Thread wormwood_3
kype - shuckins From: bob gailer To: wormwood_3 Cc: tutor@python.org Sent: Sunday, December 28, 2008 9:07:12 PM Subject: Re: [Tutor] Printing the code of a function wormwood_3 wrote: Hello all, This might be trivially easy, but I was having a hard time searching on it since al

[Tutor] Printing the code of a function

2008-12-28 Thread wormwood_3
Hello all, This might be trivially easy, but I was having a hard time searching on it since all the component terms are overloaded:-) I am wondering if there is a way to print out the code of a defined function. So if I have: def foo(): print "Show me the money." then I would like to do so

[Tutor] Logging in Linux

2007-10-23 Thread wormwood_3
Hello tutors, I have become familiar with the basic use of the logging module. I have a program that prints out warning messages as well as info messages as it runs, merely dumping them into stdout. When I make such a script into a cron job, I simply redirect this output to /dev/null. Now, wha

Re: [Tutor] Updating MySQL Database

2007-10-10 Thread wormwood_3
I loved that strip so much. I printed it today, and it is on the door of our IT office:-) - Original Message From: Kent Johnson <[EMAIL PROTECTED]> To: Python Tutorlist Sent: Wednesday, October 10, 2007 8:52:12 AM Subject: Re: [Tutor] Updating MySQL Database Kent Johnson wrote: > It

Re: [Tutor] Finding a project

2007-10-09 Thread wormwood_3
When I started out (not long ago), I started working on projects I had the need for. I have done a lot of small sysadmin projects, and they have all been things I found I needed or would help me doing sysadmin work. Try to think of tasks you have to often do that are at all subject to automati

[Tutor] Missing LOTS of list messages

2007-10-09 Thread wormwood_3
Hello tutors, I just discovered again that I am missing lots of messages from the list. Compared to this: http://www.nabble.com/Updating-MySQL-Database-t4585380.html where 8 messages are listed, my email client shows 5. They are not in spam, I just never got them. Since this is the third time I

Re: [Tutor] Updating MySQL Database

2007-10-08 Thread wormwood_3
n, ip) * I will try a first version with a single connection and close, looping through executes in the middle. Should have thought of that first... Thanks again, Sam _____ - Original Message From: Eric Walstad <[EMAIL PROTECTED]> To: wormwood_3

[Tutor] Updating MySQL Database

2007-10-07 Thread wormwood_3
Hello all, I have a script which takes data from a file or MySQL DB, looks up some stuff, then can print results to console or file. I would also like it to be able to update a MySQL database with the results. Does anyone have any ideas on how to do this? I can update records just fine, but wha

[Tutor] Logging with proper format

2007-10-07 Thread wormwood_3
Sent this almost an hour ago, did not get it from the list yet. No idea why, but sending again... -- Hello tutors, I am adding logging to a program I am writing. I have some messages I want to log that are rather long. The problem I am running into is that when the line

[Tutor] Logging with proper format

2007-10-07 Thread wormwood_3
Hello tutors, I am adding logging to a program I am writing. I have some messages I want to log that are rather long. The problem I am running into is that when the line is more than the 80 character line recommendation and I split it across 2 lines with "\", the output is affected. Example c

Re: [Tutor] Really basic web templating

2007-10-01 Thread wormwood_3
that they are similar to WebFaction, but having that much flexibility, with the base plan only ~$8/month, is pretty awesome. -Sam - Original Message From: Kent Johnson <[EMAIL PROTECTED]> To: wormwood_3 <[EMAIL PROTECTED]> Cc: Python Tutorlist Sent: Monday, October 1, 200

Re: [Tutor] Really basic web templating

2007-10-01 Thread wormwood_3
t;[EMAIL PROTECTED]> To: wormwood_3 <[EMAIL PROTECTED]> Cc: Python Tutorlist Sent: Monday, October 1, 2007 6:44:45 AM Subject: Re: [Tutor] Really basic web templating wormwood_3 wrote: > I want > to do this because my site is on a shared hosting account, so I cannot > install a

Re: [Tutor] Really basic web templating

2007-09-30 Thread wormwood_3
, etc. Perhaps this is just another area of CGI that I missed and have not seen tutorials on. If it is and you have seen some, please share! -Sam - Original Message From: Ian Witham <[EMAIL PROTECTED]> To: wormwood_3 <[EMAIL PROTECTED]> Cc: Python Tutorlist

[Tutor] Really basic web templating

2007-09-30 Thread wormwood_3
Hello all, I am trying to think of a way to make this happen, but it may not be at all possible:-) I would like to use Python to generate pages on demand for my website. By this I mean, when someone hits www.mysite.com/pagex.html, I want to generate the page pagex.html via a Python script. I h

Re: [Tutor] CGI File Woes

2007-09-30 Thread wormwood_3
Those examples were a lot of help Martin. Turned out the only issue was that I did not have this line right: print "Content-type: text/html\n\n" With that form, it loaded just fine. It had been running fine from the terminal, but without this line being right, Apache did not know what to do wi

Re: [Tutor] CGI File Woes

2007-09-30 Thread wormwood_3
>>Did you mean for there to be two tags or is it a typo? Just a typo. Should not have a big effect, but it has been fixed. >>I've never used cgitb (and until now didn't know it existed!) >>so can't comment. I had not heard of it until this week when I started working on CGI stuff, but I have f

[Tutor] CGI File Woes

2007-09-29 Thread wormwood_3
Hello all, I am working on a very simple CGI script. The site I want to use it on is a shared linux host, but I confirmed that .py files in the right dir with the right permissions and shebang execute just fine, Hello World sort of tests were successful. So now something a little more involved

Re: [Tutor] linux terminal coloring in python

2007-09-29 Thread wormwood_3
Hello, I actually wanted/looked for colored output in the CLI for quite a while myself, and finally found the solution! The magic?: "echo -e". The syntax is a little odd to use it, and I don't think I can explain it very succinctly. It may be best to see an example of it in action. I wrote a ba

Re: [Tutor] Adding a GUI

2007-09-16 Thread wormwood_3
Hi, >> Wormwood, an easier way to create a crossplatform GUI than raw wxPython is >> to use pythoncard, which is a library that is on top of wxPython that is >> there to make it easier to use and to make it easier to >> layout GUI screens/dialogs. I have heard some good things about pythoncar

[Tutor] Adding a GUI

2007-09-16 Thread wormwood_3
>> First of all Sam, thanks for your help with the fileinput() problem I >> was having! =) Sure thing:-) Sorry I could not actually solve it! I am still have a hard time getting my mind around the line.strip(), then printing based on a condition loop. Not sure why... The excerpt from Lutz' boo

Re: [Tutor] Adding a GUI

2007-09-15 Thread wormwood_3
still remains the same:-) -Sam - Original Message From: Dotan Cohen <[EMAIL PROTECTED]> To: wormwood_3 <[EMAIL PROTECTED]> Sent: Sunday, September 16, 2007 2:21:53 AM Subject: Re: [Tutor] Adding a GUI On 16/09/2007, wormwood_3 <[EMAIL PROTECTED]> wrote: > Hi all, >

[Tutor] Adding a GUI

2007-09-15 Thread wormwood_3
Hi all, I am just starting to learn GUI programming, with wxPython. I have a script that that I have developed to a useful point, and I want to add a GUI to it. I am a little unsure as the the best approach to this. The script heretofore was just run at the command line. Would it make sense to

Re: [Tutor] Loop optimization

2007-09-15 Thread wormwood_3
Kent, You replied with the following some time ago regarding a question I asked about optimizing a loop: >> You should try an optimized for loop: >> append_ = self.potdomains.append_ >> s1_ = suffix1 >> s2_ = suffix2 >>

Re: [Tutor] vi and python

2007-09-14 Thread wormwood_3
Hello, I go back and forth between SPE and VIM for Python myself. As for Python support in VIM, you can use most editions of VIM as a plain text editor, and it is fine for Python. But, if you install vim-python (http://ddtp.debian.net/ddt.cgi?desc_id=20183), you get some nice added features su

Re: [Tutor] deleting one line in multiple files

2007-09-13 Thread wormwood_3
Thought I would do some more testing and get you a more finalized form this time. So I took the mygrep.py script, and put it in a folder with 3 test files with content like this: I am some lines of text yep I love text 435345 345345345 Then I ran: [EMAIL PROTECTED]:~/test$ python mygrep.py "

[Tutor] deleting one line in multiple files

2007-09-13 Thread wormwood_3
I think the problem is that the original script you borrowed looks at the file passed to input, and iterates over the lines in that file, removing them if they match your pattern. What you actually want to be doing is iterating over the lines of your list file, and for each line (which represent

Re: [Tutor] interpreted or compiled?

2007-09-12 Thread wormwood_3
Michael, The most common method I know of to do this is py2exe: http://www.py2exe.org/ This lets you turn scripts into executable Windows programs. A different, and perhaps better, method is PyInstaller: http://pyinstaller.python-hosting.com/ This creates executables for Windows and Linux.

Re: [Tutor] Image Analysis

2007-09-12 Thread wormwood_3
some neat things in it. -Sam - Original Message ---- From: wormwood_3 <[EMAIL PROTECTED]> To: Python Tutorlist Sent: Wednesday, September 12, 2007 9:21:28 AM Subject: Re: [Tutor] Image Analysis Very strange. This is the second time that I know of in the last month that I have n

Re: [Tutor] Image Analysis

2007-09-12 Thread wormwood_3
Very strange. This is the second time that I know of in the last month that I have not received some emails from the list. I did not get the message Eike Welk sent out. Checking archives... - Original Message From: Dave Kuhlman <[EMAIL PROTECTED]> To: tutor@python.org Sent: Tuesday, Se

Re: [Tutor] Image Analysis

2007-09-11 Thread wormwood_3
ject: Re: [Tutor] Image Analysis "wormwood_3" <[EMAIL PROTECTED]> wrote > I need some way to analyze an image for color patterns. > > My only lead right now is PIL, and I am not sure if it will meet my > needs. I am using PIL and numpy # something hat at leas

Re: [Tutor] Socket Timeout Handling

2007-09-11 Thread wormwood_3
Ok, just found your message in the archives. Thanks very much for that! By way of response-- >>That may be because your question ventures into fairly deep areas of >> networking >> that most folk who are just learning Python(ie readers of this list) >> have probably >> not encountered. True

Re: [Tutor] Socket Timeout Handling

2007-09-11 Thread wormwood_3
>I did send you a response and it is listed on the gmane archive >so if you didn't see it something has gone adrift somewhere. Just searched all my mail, for some reason I did not get this. I will check the archive. Thanks! >The solution you posted seems to bear no resemblence >to the problem yo

[Tutor] Image Analysis

2007-09-10 Thread wormwood_3
I have thought up a project for myself that is rather beyond my current knowledge, but I think it will be fun and very informative. I'll leave out the details right now, but the task that will be the hardest is that I need some way to analyze an image for color patterns. I would like to be able

Re: [Tutor] making math problems mmmm fun

2007-09-10 Thread wormwood_3
Don't have any ideas to Pythonize this problem for you, but I must say that I hope this problem was listed in a chapter entitled "Cruel and Unusual"! -Sam - Original Message From: max baseman <[EMAIL PROTECTED]> To: tutor@python.org Sent: Monday, Sept

Re: [Tutor] Socket Timeout Handling

2007-09-10 Thread wormwood_3
be even safer, would could check against several reliable sites, such as Amazon, Yahoo, w3c.org, etc. The status of each check could be put in a list, and if any list item was networkup, then the internet connection may be considered up. Hope someone finds this useful. -Sam ___

Re: [Tutor] Socket Timeout Handling

2007-09-06 Thread wormwood_3
: wormwood_3 <[EMAIL PROTECTED]> To: Python Tutorlist Sent: Thursday, September 6, 2007 9:40:21 AM Subject: [Tutor] Socket Timeout Handling I am trying to figure out the optimal way to make socket connections (INET) and check for timeouts. The socket module has settimeout(timeou

[Tutor] Socket Timeout Handling

2007-09-06 Thread wormwood_3
I am trying to figure out the optimal way to make socket connections (INET) and check for timeouts. The socket module has settimeout(timeout) and setdefaulttimeout(timeout). However, so far as I can tell, these apply to socket objects. The type of socket connection I want to make is getfqdn(add

[Tutor] Integer ID Caching

2007-09-04 Thread wormwood_3
I came across the topic of internal Python IDs recently, and learned that the internal numeric ids of small integers are cached to increase speed. I had read that as of 2.5, this applied to integers between -1 and 100. However, doing some quick tests, this seems not to be accurate: Python 2.5.1

[Tutor] Equivalent of && in Python?

2007-08-27 Thread wormwood_3
I have a script that reads some local system information, performs some calculations, and then launches some terminal windows: # Spawn the 4 terminals, with needed positions and sizes, then exit commands.getoutput("%s --geometry=%dx%d+%d+%d --working-directory=%s" % \ (terminal, t1width, t1he

Re: [Tutor] Spawning terminals from Python - A failed question

2007-08-24 Thread wormwood_3
>>Umm, so just put the ampersand at the end of the command string and >>call os.system() Not sure what the point of this variation would be if os is being deprecated along with commands... >>However both os.system and the commands module are deprecated in >>favour >>of the new(ish) subprocess m

[Tutor] Spawning terminals from Python - A failed question

2007-08-24 Thread wormwood_3
Hello all, I had this question all written up, then found I had the answer:-) So I decided to share anyway in case anyone found it useful -- I am trying to write a script that will open terminal windows for me, based on certain criteria. In this case, gnome-termin

[Tutor] Floating Confusion

2007-08-22 Thread wormwood_3
Dear Tutors, Reading through Wesley's delightful Core Python Programming, I came across something I have not been able to grasp yet. Some introductory code: >>> 1 1 >>> 1.1 1.1001 >>> print 1 1 >>> print 1.1 1.1 The second case is, of course, what is throwing me. By having a decim

Re: [Tutor] Loop optimization

2007-08-20 Thread wormwood_3
I ran a few tests, with the following results: 1. Timing using the time module: * Using for loop, src code: import time start = time.time() for word in self.dictcontents: self.potdomains.append(word + suffix

Re: [Tutor] Loop optimization

2007-08-20 Thread wormwood_3
>I think what you have is pretty clear. I can't think of a way to do this >with a single list comprehension because you add two items to the list >each time through the loop. You could use a list comp and a generator >expression, but the order of entries in the result will be different: >self.po

[Tutor] Loop optimization

2007-08-20 Thread wormwood_3
Hello tutors, I am trying to understand the best cases in which to use for loops, list comprehensions, generators, and iterators. I have a rather simple process that I made initially as a for loop: self.potdomains = [] for word in self.dictcontents: self.potdomains.a

Re: [Tutor] Python Book Recommendations [Was:[Re: Security]]

2007-08-16 Thread wormwood_3
Yeah, I loved this! I did not even know you could put variables and keywords in bookmarks like this. Awesomely cool. For anyone interested in more details, Lifehacker has a great article on this, associated plugins, tips and tricks: http://lifehacker.com/software/bookmarks/hack-attack-firefox-a

Re: [Tutor] Bookpool sale on Addison Wesley

2007-08-09 Thread wormwood_3
Thanks for the heads up! I have been looking to get Core Python Programming for a while now. ___ - Original Message From: Kent Johnson <[EMAIL PROTECTED]> To: Tutor@python.org Sent: Wednesday, August 8, 2007 6:31:46 PM Subject: [Tutor] Bookpool sale on Addison

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread wormwood_3
>>You can use d.__getitem__ as the key function for a sort of the keys. >>__getitem__() is the special method that is called for indexing a >>dictionary (or a list). Just curious: Is there a reason to use __getitem__() over itemgetter (used in the example in my reply)? >>In [24]: d = {'a':21.3

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread wormwood_3
>>hello there all, >>i am wondering how to sort a dictionary that i have by values. >>And i also need to sort them from greatest to least >>like if i have a dictionary >> >>d = {'a':21.3, 'b':32.8, 'c': 12.92} >> >>how could i sort these from least to greatest >>so that the order would turn out >>b

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
> Traceback (most recent call last): > File "domainspotter.py", line 150, in >runMainParser() > File "domainspotter.py", line 147, in runMainParser >td.run() > File "domainspotter.py", line 71, in run >checkdomains.lookup() > File "domainspotter.py", line 108, in lookup >from r

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Probably you need to import NoSuchDomain from rwhois: >>from rwhois import WhoisRecord, NoSuchDomain >> >>then use >> except NoSuchDomain: I tried adding: from rwhois import WhoisRecord, NoSuchDomain who = WhoisRecord() self.totalchecked = 0 self.availdomains =

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Examining rwhois.py reveals >>raise 'NoSuchDomain' >>>which is a string exception. Which should work even tho deprecated. >>>When you say it did not work what is the evidence? -- Bob Gailer 510-978-4454 Oakland, CA 919-636-4239 Chapel Hill, NC ___ I did s

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
>>Probably you need to import NoSuchDomain from rwhois: >>from rwhois import WhoisRecord, NoSuchDomain >> >>then use >> except NoSuchDomain: That sounds right, I will give it a shot soon. >>In general, when you ask a question here, "I tried X and it did not >>work" is not very informative and

[Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
Hi all, I am new to Python programming and this list, looks like a great place so far! Recently I was trying to do a "try: X except Y: Z" statement, checking for a custom error code that the rwhois.py module throws. Some details on the exercise and the full code can be found on this post ( htt

[Tutor] Checking for custom error codes

2007-08-07 Thread wormwood_3
Hi all, I am new to Python programming and this list, looks like a great place so far! Recently I was trying to do a "try: X except Y: Z" statement, checking for a custom error code that the rwhois.py module throws. Some details on the exercise and the full code can be found on this post ( htt