Re: [Tutor] What Editori?

2010-02-23 Thread Christian Witts
://mail.python.org/mailman/listinfo/tutor I use Spyder mainly, also have Geany, SciTe, and Emacs setup but I like Spyder for pyLint right there, console inside, the ability to run applications in seperate threads and many more useful features. -- Kind Regards, Christian Witts

Re: [Tutor] Python and algorithms

2010-02-18 Thread Christian Witts
http://www.brpreiss.com/books/opus7/html/book.html -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to delete the last line from a file efficiently?

2010-02-18 Thread Christian Witts
. As for how fast it is by comparison, I unfortunately don't have time to benchmark it. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python and algorithms

2010-02-18 Thread Christian Witts
the math background and worked out how to efficiently solve problems. Thanks, Todd Christian Witts wrote: C.T. Matsumoto wrote: Hello Tutors, Can someone point me to any resources that can teach me about algorithms in python? I'm interested in learning how to analyze and make an algorithm

Re: [Tutor] Problem with input in Python 3

2010-02-15 Thread Christian Witts
allowing input until the person enters 3 numbers seperated purely by commas in for input. -- Kind Regards, Christian Witts Business Intelligence C o m p u s c a n | Confidence in Credit Telephone: +27 21 888 6000 National Cell Centre: 0861 51 41 31 Fax: +27 21 413 2424 E-mail: cwi...@compuscan.co.za

Re: [Tutor] Simple Stats on Apache Logs

2010-02-11 Thread Christian Witts
like {Date: {Keyword1: Count, Keyword2: Count}. Essentially you would just iterate over the file, check if the line contains your keyword(s) that you are looking for and then incrementing the counter for it. -- Kind Regards, Christian Witts Business Intelligence C o m p u s c a n | Confidence

Re: [Tutor] string to list

2010-02-10 Thread Christian Witts
be really careful with its usage. If I remember correctly there was a recipe for safe parsing on http://code.activestate.com/ but I don't seem to have the link at hand. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org

Re: [Tutor] how to clear contents of a file

2010-02-09 Thread Christian Witts
://mail.python.org/mailman/listinfo/tutor You can just open the file again in write mode which will truncate it for you. So, f = open(filename, 'w') will clear the contents of your filename (don't forget to close the file when you're done if you do this though). -- Kind Regards, Christian Witts

Re: [Tutor] Dictionary Comprehensions

2009-12-06 Thread Christian Witts
___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Are you maybe looking for `dc = {y:x for y,x in zip('khalid', range(6))}` ? -- Kind Regards, Christian Witts

Re: [Tutor] Can't loop thru file and don't see the problem

2009-12-04 Thread Christian Witts
, or does it depend on the file format? I will eventually be working with Excel and possibly mssql tables. Thanks again for your help. Roy On Thu, Dec 3, 2009 at 3:46 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Roy Hinkelman wrote: Your list

Re: [Tutor] Can't loop thru file and don't see the problem

2009-12-03 Thread Christian Witts
subscription options: http://mail.python.org/mailman/listinfo/tutor Hope the comments above help in your endeavours. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Nested loop of I/O tasks

2009-11-24 Thread Christian Witts
is in dictionary. It would also work for this scenario of perfect data as well. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman

Re: [Tutor] Adding Value to CSV

2009-11-02 Thread Christian Witts
. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Can't find modules at command line

2009-11-02 Thread Christian Witts
In the console when you start it up you appear to be in your home directory `~` but your script is in the Documents folder so you will need to add Documents to your path for eg. from sys import path path.append('/path/to/script/to/be/imported') import gun -- Kind Regards, Christian Witts

Re: [Tutor] python zlib problem

2009-11-01 Thread Christian Witts
or change subscription options: http://mail.python.org/mailman/listinfo/tutor You can take a look at this link and see if it can help you http://www.1stbyte.com/2005/06/26/configure-and-compile-python-with-zlib/ -- Kind Regards, Christian Witts ___ Tutor

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
listed in the TODO. Advise is appreciated. On Mon, Oct 26, 2009 at 2:12 PM, Luke Paireepinart rabidpoob...@gmail.com mailto:rabidpoob...@gmail.com wrote: On Mon, Oct 26, 2009 at 3:20 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: fInput

Re: [Tutor] Compute data usage from log

2009-10-27 Thread Christian Witts
asking as I'm away from my linux box atm. for line in open(log_file): last_log_date = ' '.join(line.split(' ')[:3]) Thanks. On Tue, Oct 27, 2009 at 2:56 PM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: bibi midi wrote: #!/usr/bin/env python

Re: [Tutor] How to load a dict into a dict subclass?

2009-10-27 Thread Christian Witts
': 200} -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Compute data usage from log

2009-10-26 Thread Christian Witts
), converts it into an integer and adds it to your total_usage counter. Of course this has no error checking and or niceties, but I will leave that up to you. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org

Re: [Tutor] if clause in list comprehensions.

2009-10-21 Thread Christian Witts
. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Most pythonic input validation

2009-10-16 Thread Christian Witts
be able to type in on the console. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Most pythonic input validation

2009-10-16 Thread Christian Witts
single time you try to make a choice rendering it slower than `if start = choice = stop`, although on a small choice set the speed difference would hardly be noticeable. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org

Re: [Tutor] ok i need some help with a for loop

2009-10-15 Thread Christian Witts
'You used a word I did not understand' because the success variable is still False. This is just a rather basic idea, but it will get the job done. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] Bounces

2009-10-08 Thread Christian Witts
/listinfo/tutor This one came through, I also have 57 emails originating from you since the 8th of July 2009. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] Beginners question

2009-10-08 Thread Christian Witts
guess is incorrect it would just loop infinitely (it's currently 1 level of indentation out, as well as your `tries += 1`). Welcome to Python and hope you enjoy your stay. :) -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Checking for Python version

2009-10-06 Thread Christian Witts
(Please upgrade to Python 2.4 or greater.) -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Checking for Python version

2009-10-06 Thread Christian Witts
Todd Zullinger wrote: Christian Witts wrote: Your version will fail if the person is running Python 3.0, 3.1 up until the 3.3 series which is not good. Neater looking (imo) code below. from sys import version_info, exit if version_info[0] == 1 or (version_info[0] == 2 and version_info[1

Re: [Tutor] (no subject)

2009-09-09 Thread Christian Witts
subscription options: http://mail.python.org/mailman/listinfo/tutor That would need to have a starting value of -1 and an end value of -(len(phrase)+1). Of else you can start at length - 1, end at zero and a step value of -1. -- Kind Regards, Christian Witts

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Christian Witts
://mail.python.org/mailman/listinfo/tutor s = 'Büro' for ch in s: ... print ch ... B � r o You need to make it a unicode string. s = u'Büro' for ch in s: ... print ch ... B ü r o -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org

Re: [Tutor] How to iterate through unicode string.

2009-09-04 Thread Christian Witts
this python code k = [] s = u'Büro' for c in s: k.append(c) print k k=[u'B', u'\xa8', u'\xb9', u'r', u'o'] i still have 5 different chars. 2009/9/4 Christian Witts cwi...@compuscan.co.za zhang allen wrote: Hi All, Say i have unicode string * Büro*. i want to iterate

Re: [Tutor] running python program on Linux Virtual Server - Plesk?

2009-09-03 Thread Christian Witts
better off calling a shell script with the cron job and in the shell script listing certain environment variables you might need and then calling the script. The job won't be running under your normal user account so you might need to add them. -- Kind Regards, Christian Witts

Re: [Tutor] running python program on Linux Virtual Server - Plesk?

2009-09-03 Thread Christian Witts
? MIke On Thu, Sep 3, 2009 at 2:45 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Michael Yang wrote: Hi Everyone, I'm new to programming and to python. I have a program I want to run on my Media Temple Virtual Server (dv) - Linux

Re: [Tutor] I always get this message as a reply

2009-09-02 Thread Christian Witts
for ages. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help...

2009-07-28 Thread Christian Witts
of that function there are no variables names burgerPrice, friesPrice or sodaPrice. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
file.split('.svg')[0] You could also use split to get rid of the Flag_of_ by doing file = file.split('.svg')[0].split('_')[2] or you could use replace for it file = file.split('.svg')[0].replace('Flag_of_', '') -- Kind Regards, Christian Witts ___ Tutor

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
: # Dictionaries can be accessed this way and it looks cleaner. new_filename = 'flag-%s.svg' % countries[fn] # String formatting is neater and faster than concatenation rename(filename, new_filename) -- Kind Regards, Christian Witts

Re: [Tutor] Replace a character by index

2009-07-16 Thread Christian Witts
simpler and faster to just use the strings build in index and item assignment. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Christian Witts
Chris Castillo wrote: why does your 3rd and fourth lines have brackets? On Thu, Jul 16, 2009 at 1:08 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Chris Castillo wrote: I'm having some trouble reading multiple data types from a single

Re: [Tutor] Replace a character by index

2009-07-16 Thread Christian Witts
Wayne wrote: On Thu, Jul 16, 2009 at 4:06 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: snip Strings are essentially a list already of characters. What would be slowing down your preferred method #1 would be your explicit cast to a list

Re: [Tutor] reading complex data types from text file

2009-07-16 Thread Christian Witts
sue above average jim perfect On Thu, Jul 16, 2009 at 4:12 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Chris Castillo wrote: why does your 3rd and fourth lines have brackets? On Thu, Jul 16, 2009 at 1:08 AM, Christian Witts cwi

Re: [Tutor] How to pass command line variables to this python code...

2009-07-15 Thread Christian Witts
: ['selenium-google-test.py', 'yankees'] so args = sys.argv args[0] == 'yankees' True That would be false, the first argument (list index zero) is the script name. You would need to do args = sys.argv[1:] if you want to dump the filename from the list. -- Kind Regards, Christian Witts

Re: [Tutor] reading complex data types from text file

2009-07-15 Thread Christian Witts
like with the lists. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] assigning list to keys

2009-07-14 Thread Christian Witts
etc as you can very easily end up with unexplained errors. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python Programming exercise

2009-07-01 Thread Christian Witts
if it doesn't match still you will need to do a .strip() on your guess. Hope that helps. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] character counter

2009-06-29 Thread Christian Witts
or if it is just printable characters then maybe look at string translation tables and the string.replace methods to cull out what you do not need. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo

Re: [Tutor] Print on 3.1 for Mac?

2009-06-29 Thread Christian Witts
. print(Hello world!) -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] [Fwd: Re: Print on 3.1 for Mac?]

2009-06-29 Thread Christian Witts
Forwarding to the list. Original Message Subject:Re: [Tutor] Print on 3.1 for Mac? Date: Mon, 29 Jun 2009 12:38:43 +0100 From: andré palma andre...@gmail.com To: Christian Witts cwi...@compuscan.co.za References: ac56af79a36314157de09d7d78770ffa.squir

Re: [Tutor] syntax error

2009-06-25 Thread Christian Witts
? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Python 3.0+ print has been changed to a function so you need to do print(Hello World!) -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] Can't figure out why this is printing twice

2009-06-08 Thread Christian Witts
/listinfo/tutor Running from a console the expected output would actually be 06-08-2009.gz The name of the file will be 06-08-2009.gz Other than that side effect it works with only 1 print. -- Kind Regards, Christian Witts Data Management C o m p u s c a n | Confidence in Credit Telephone: +27 21

Re: [Tutor] Hi

2009-06-08 Thread Christian Witts
your stay. :) -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] CVS File Opening

2009-05-27 Thread Christian Witts
] == ['142', '152']: print IP, Cnt Obviously if you want to keep the original log line then you will need to store that in your dictionary as well, but for the purpose of reporting how many 'offences' an IP Address has had this is simple enough. -- Kind Regards, Christian Witts

Re: [Tutor] CVS File Opening

2009-05-27 Thread Christian Witts
Paras K. wrote: There are no headers for the log files, and there are mulitple log files so what that walk through the directory for all csv files? THANK IN ADVANCE!!! On Wed, May 27, 2009 at 10:18 AM, Christian Witts cwi...@compuscan.co.za mailto:cwi...@compuscan.co.za wrote: Paras K

Re: [Tutor] Python Function Doubt

2009-05-26 Thread Christian Witts
the Mutable defaults for function/method arguments section of http://www.ferg.org/projects/python_gotchas.html#contents_item_6 Hope that helps your understanding. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] ?????

2009-05-25 Thread Christian Witts
this, just wondering about the use case for such automation ? -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ?????

2009-05-25 Thread Christian Witts
prasad rao wrote: Any particular reason why you need to be able to do this, just wondering about the use case for such automation ? -- Kind Regards, Christian Witts Thank you Christian for the prompt repply. I am learning python. I am just examining what are all

Re: [Tutor] ?????

2009-05-25 Thread Christian Witts
for such automation ? -- Kind Regards, Christian Witts Hello It is printing wether the item is callable or not. I want it to print sys.getdefaultencoding ASCII sys.getfilesystemencoding mbcs Like that Prasad My apologies, didn't double check. It should be: for attrib in dir

Re: [Tutor] delphi, pascal and Python

2009-05-20 Thread Christian Witts
Take a look at this topic http://forum.qgis.org/viewtopic.php?f=5t=4341 It's from November 2008 so should still be current. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Iterating over list of functions

2009-05-20 Thread Christian Witts
to do the heavy lifting for you import string funcs = {1:string.upper, 2:string.lower} funcs[1]('this is a simple test') 'THIS IS A SIMPLE TEST' funcs[2]('THIS IS A SIMPLE TEST') 'this is a simple test' -- Kind Regards, Christian Witts ___ Tutor

Re: [Tutor] Sorting a list

2009-05-14 Thread Christian Witts
, None, None] numeric_list.sort(); string_list.sort(); numeric_list, string_list ([3, 4, 6, 9], ['word']) string_list.extend(numeric_list) string_list ['word', 3, 4, 6, 9] -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] (a, b) = (l[0:2], l[2:])

2009-05-13 Thread Christian Witts
) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor What you are doing is already fine although you can drop the starting index for the first slice l=[1,2,3,4,5,6,7,8,9,10] l[:2], l[2:] ([1, 2], [3, 4, 5, 6, 7, 8, 9, 10]) -- Kind Regards, Christian Witts

<    1   2