Re: [Tutor] Converting a string into dictionary references

2012-04-23 Thread Christian Witts
cut to do the work for you for eg and it might simplify your workflow. -d specifies the delimiter of the file, in this case a comma -f specifies the fields you want, in this case 1 to 3, 5, and 10 cut -d, -f1-3,5,10 input_filename > output_filename -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] user created lists

2012-04-12 Thread Christian Witts
On 2012/04/12 08:59 AM, Peter Otten wrote: Christian Witts wrote: On 2012/04/12 06:42 AM, john moore wrote: Hello Pyhton World, I'm new at this and was wondering how I create a number of user specified lists? Example: "How many list would you like to create?" User inputs

Re: [Tutor] user created lists

2012-04-11 Thread Christian Witts
ange/xrange doesn't include the top number for i in xrange(1, user_input + 1): vars()['list%s' % i] = [] Hope that helps. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] need help with a script..

2012-04-11 Thread Christian Witts
there's no explicit printing of the resulting list it will never get displayed to your console. Whereas when you run it from IDLE it will implicitly print the return value of a function if you do not "save" the data to a variable. -

Re: [Tutor] ADO with python 2.6 without additional installs

2012-04-10 Thread Christian Witts
.no> --- *Fra:*Christian Witts [mailto:cwi...@compuscan.co.za] *Sendt:* 10. april 2012 11:24 *Til:* Bakkestuen Roger *Kopi:* tutor@python.org *Emne:* Re: [Tutor] ADO with python 2.6 w

Re: [Tutor] ADO with python 2.6 without additional installs

2012-04-10 Thread Christian Witts
Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor You can give PyODBC [1] a try as it does support MS Access [2]. [1] http://code.google.com/p/pyodbc/ [2] http://code.google.com/p/pyodbc/wiki/ConnectionStri

Re: [Tutor] New to Python programing

2012-04-03 Thread Christian Witts
Stanford University programming courses, and there are many Python specific vidoes there as well. Just something else to check out. Are you possibly thinking of the Khan Academy [1] ? [1] http://www.khanacademy.org/ -- Christian Witts Python Developer // __

Re: [Tutor] (no subject)

2012-03-27 Thread Christian Witts
on a closed file, and your traceback indicates it is when you're iterating over it. As the error occurs in your argument.py file, you should post the relevant portions of that code too. You could also do `cat file1 file2 filen > final_file` in a *nix prompt if that is your use-case. --

Re: [Tutor] Refactoring

2012-03-08 Thread Christian Witts
efactoring: Improving The Design Of Existing Code [1] As for Python IDEs that have built-in refactoring tools, I know of PyCharm [2] which handles it. [1] http://martinfowler.com/refactoring/ [2] http://www.jetbrains.com/pycharm/features/ -- Christian Witts Python

Re: [Tutor] Question about writing to Excel with slavic characters

2012-03-05 Thread Christian Witts
s(""" + analysis[0] + """) print(baza$demo_izob0) """) Now when my text data labels in spss have slavic characters, they are not recognised and output is something like that: stiriletna srednja �ola nedokon�ana osnovna �ola What should I do here? Thanks a l

Re: [Tutor] Question about writing to Excel with slavic characters

2012-03-05 Thread Christian Witts
http://mail.python.org/mailman/listinfo/tutor What package are you using to create your Excel workbook ? If it's xlwt you can set your encoding type when you create your workbook book = xlwt.Workbook(encoding="utf-8") -- Christian Wi

Re: [Tutor] Writing to a file/changing the file name

2012-02-22 Thread Christian Witts
've changed the name, and for that you can use os.path.splitext >>> import os >>> filename, extension = os.path.splitext('recipe.txt') >>> print (filename, extension) ('recipe', '.txt') >>> new_filename = filename + '2&#

Re: [Tutor] '__name__' == '__main__'

2012-02-20 Thread Christian Witts
rom t2' $ cat t2.py import t1 $ python t1.py Executed from __main__ $ python t2.py Executed by import from t2 $ cat t3.py if __name__ == '__main__': print 'Executed from __main__' else: print 'Executed by import' $ cat t4.py import t3 $ python t3.

Re: [Tutor] Where can I download the document for twisted?

2012-02-10 Thread Christian Witts
n.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor There a link to "The complete developer guide in PDF Format" on http://twistedmatrix.com/trac/wiki/Documentation -- Christian Witts P

Re: [Tutor] 回复: Re: What the difference between the two RE?

2012-02-09 Thread Christian Witts
On 2012/02/09 10:17 AM, daedae11 wrote: So doesn't it means the follow two sentences can achieve the same goal? re.match("^hello", "hello") re.match("hello", "hello") ---

Re: [Tutor] What the difference between the two RE?

2012-02-09 Thread Christian Witts
e line" so 'And they said hello' will not be matched by the regex pattern '^hello'. The docs are pretty good on the module http://docs.python.org/library/re.html http://docs.python.org/howto/regex.html -- Christian Witts Python Developer // -- From

Re: [Tutor] What the difference between the two RE?

2012-02-08 Thread Christian Witts
"At the beginning of the line" so 'And they said hello' will not be matched by the regex pattern '^hello'. The docs are pretty good on the module http://docs.python.org/library/re.html http://docs.python.org/howto/regex.html -- Christian Witts Python Developer /

Re: [Tutor] Character Buffer Object Error

2012-02-07 Thread Christian Witts
stinfo/tutor new_char is of type int and not type str, so cast it back to a string before using it in your call to .replace as it expects both arguments to be strings. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Lists/raw_input

2012-02-06 Thread Christian Witts
otherwise prompt the user to re-enter them Hope that help. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] ASCII Conversion

2012-01-30 Thread Christian Witts
ore hand. Hope that helps. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] loop until a keypress

2012-01-30 Thread Christian Witts
ent module for capturing keystrokes unfortunately. You can take a look at this StackOverflow answer though which could help you out http://stackoverflow.com/questions/5044073/python-cross-platform-listening-for-keypresses -- Christian Witts Python Developer //

Re: [Tutor] exception about "ctrl+c"

2012-01-09 Thread Christian Witts
wanted. Also, Python does not require semi-colons to denote the end-of-line. It can be used if you want to have multiple statements on a single line though. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscri

Re: [Tutor] unable to use find(), index()

2011-12-08 Thread Christian Witts
gt;> help(''.find) Help on built-in function find: find(...) S.find(sub [,start [,end]]) -> int Return the lowest index in S where substring sub is found, such that sub is contained within s[start:end]. Optional arguments start and end are interpreted as in slice no

Re: [Tutor] how to calculate program compile time?

2011-12-08 Thread Christian Witts
python.org/library/timeit.html [2] http://wiki.python.org/moin/PythonSpeed/PerformanceTips -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Random order program

2011-11-28 Thread Christian Witts
On 2011/11/28 11:37 AM, Peter Otten wrote: Christian Witts wrote: Is there anything wrong with just doing the following ? from random import shuffle # just type words with space separating the items # ie. one two three four five words = input('Please enter a list of words: ')

Re: [Tutor] Random order program

2011-11-28 Thread Christian Witts
t doing the following ? from random import shuffle # just type words with space separating the items # ie. one two three four five words = input('Please enter a list of words: ') word_list = words.split() print word_list shuffle(word_list) print word_list -- Christian Witts Python Developer

Re: [Tutor] how to delete some quasi-duplicated keys

2011-11-25 Thread Christian Witts
On 2011/11/25 11:15 AM, lina wrote: On Fri, Nov 25, 2011 at 5:05 PM, Christian Witts wrote: On 2011/11/25 10:41 AM, lina wrote: pairs {('66', '69'): 217, ('69', '66'): 75, ('64', '71'): 25} such as here ('66', '69

Re: [Tutor] how to delete some quasi-duplicated keys

2011-11-25 Thread Christian Witts
', '69') will be ('69', '66') if key[::-1] in pairs: try: # The first instance of the pair gets kept and the reversed gets added pairs[key] += pairs[key[::-1]] del pairs[::-1] except KeyError: print &

Re: [Tutor] Python 3 dictionary questions

2011-11-23 Thread Christian Witts
duplicate "key" values you'll need to re-look at what data structure you want to use, you can keep using a dictionary but then you'll need to change the value side of it perhaps like `{key: {key: value, key: value}}` so you end up with `{'Elway': {'Joh

Re: [Tutor] How to get module name from ImportError

2011-11-20 Thread Christian Witts
l.python.org/mailman/listinfo/tutor >>> try: ... import nothing ... except ImportError, err_msg: ... print err_msg ... No module named nothing Hope that helps. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python

Re: [Tutor] A recursion question

2011-11-18 Thread Christian Witts
Found [4, 7, 7, 4] Incrementing Count [7, 7, 4] Nothing Found [7, 4] Nothing Found [4] Incrementing Count [] Returning -1 Returning the count Returning the count Returning the count Returning the count Returning the count Returning the count Returning t

Re: [Tutor] how to understand unhashable type: 'list'

2011-11-17 Thread Christian Witts
7;70', '61', '34'], ['34', '58', '34', '58']] weight = {} for elem in list1: ... if elem.__repr__() in weight: This is cool. May I ask which role the __repr__ plays here? __repr__ is the string representatio

Re: [Tutor] how to understand unhashable type: 'list'

2011-11-17 Thread Christian Witts
On 2011/11/17 12:26 PM, lina wrote: On Thu, Nov 17, 2011 at 6:09 PM, Christian Witts wrote: On 2011/11/17 11:59 AM, lina wrote: list1 [['61', '34', '61', '34'], ['61', '35', '61', '70', '61'], [&#x

Re: [Tutor] how to understand unhashable type: 'list'

2011-11-17 Thread Christian Witts
lists. Thanks, ^_^ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor sum(1 if type(elem) == list else 0 for elem in list1) not work for you if all you want to do is count how

Re: [Tutor] positional output

2011-11-11 Thread Christian Witts
CHAR(20), COLUMN3 TIMESTAMP, COLUMN4 INTEGER, COLUMN5 DATE, COLUMN6 CHAR(40) If all you want to space it out nicely then .split(' ', 1) and '%-40s%s' % (par

Re: [Tutor] Okay, this time I tried doing a little research but no luck in solving this one.

2011-11-11 Thread Christian Witts
select it, and click Edit -> Add your Python path to the end eg. c:\python27 (you will need to seperate it from all the other entries using a semi-colon, like c:\program files;c:\windows;c:\python27) -> Click OK about 3 times till you've closed all the windows -> Open a new Command

Re: [Tutor] how to remove the coming duplication

2011-11-09 Thread Christian Witts
this you're simply iterating through the list and checking if the current element in the list is not equal to the previous element, and if so it is not a duplicate and will be added to the new list you're creating. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] assign all parameters of __init__ to class variables?

2011-11-02 Thread Christian Witts
ssign them all to self.[name] in one step? class Test(object): def __init__(self, param1, param2, param2, **kw): self.__dict__.update(locals()) self.__dict__.update(kw) I do prefer assignment by hand, just feels nicer especially when looking at it in the future. -- Chris

Re: [Tutor] Python 2.7 on Ubuntu 11.10 - Do not unintall

2011-11-01 Thread Christian Witts
re applications, but that would go against the grain of how package management is performed and how releases would need to be packaged etc. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscript

Re: [Tutor] changing dictionary to lowercase

2011-10-28 Thread Christian Witts
ibe or change subscription options: http://mail.python.org/mailman/listinfo/tutor To save yourself the try/except you can use defaultdict which is part of the collections module. from collections import defaultdict new_d = defaultdict(list) for key, value in definitions.iteritems(): new_d[key.low

Re: [Tutor] how to calculate execution time and complexity

2011-10-27 Thread Christian Witts
;o', 'g', 'l', 'e'] >>> splitWord('google', 2) ['go', 'og', 'le'] >>> splitWord('google', 3) ['goo', 'gle'] >>> splitWord('google', 4) ['goog', 'le&#

Re: [Tutor] functions and default argument

2011-10-21 Thread Christian Witts
ad here [1]. It's a better read than how I would explain it. [1] http://www.ferg.org/projects/python_gotchas.html#contents_item_6 -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscriptio

Re: [Tutor] logging question

2011-10-20 Thread Christian Witts
try: do_something_that_could_raise_exceptions() except Exception, e: log_errors(e) raise for book in results: try: checkForErrors(book) except Exception, e: do_your_other_exception_handling() -- Christian Witts Python Deve

Re: [Tutor] I am trying to print list elements but i am getting 'none'

2011-10-10 Thread Christian Witts
eturn it from your function and then when you call it you do `print getNumbers(10)` if you wish. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Calling Python Functions from Powershell scripts

2011-10-05 Thread Christian Witts
ng function [2] [1] http://jdhitsolutions.com/blog/2011/03/powershell-automatic-logging/ [2] http://powershell.com/cs/media/p/3950.aspx -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] guess age programme (please help)

2011-09-30 Thread Christian Witts
attempts have been exhausted. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] last part of my programme

2011-09-29 Thread Christian Witts
t;, line 0 Which is because input() converts the input to an integer so you would need to type for eg 0 then enter for it to exit without failing. Changing that to raw_input() like the rest of your inputs will fix that. -- Christian Witts Python Developer // ___

Re: [Tutor] How it is better than java

2011-09-19 Thread Christian Witts
org/2004/12/java-is-not-python-either.html [3] http://pypy.org/ -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What's the keyword for the Python creed?

2011-09-15 Thread Christian Witts
from __future__ import braces :) -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] _init_() arguments

2011-09-09 Thread Christian Witts
elf.r = realpart ... self.i = imagpart ... >>> x= Complex2(3.0, -4.5) Traceback (most recent call last): File "", line 1, in TypeError: this constructor takes no arguments -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] need advice about a dictionary ({})

2011-09-08 Thread Christian Witts
ve you the persistence and then when your script starts up you can unpickle the file if it exists else create a new one. Of course if you make any changes to your object you'll need to pickle it once your app finishes otherwise new changes won't be written out. With just a plain text f

Re: [Tutor] Confirmation if command worked

2011-08-25 Thread Christian Witts
On 2011/08/25 10:19 AM, Alan Gauld wrote: On 25/08/11 07:25, Christian Witts wrote: Once you call child.close() the exit and signal status will be stored in .exitstatus and .signalstatus, for a normal exit of the program .exitstatus will store the return code from SCP as per [1] [2] [3] and

Re: [Tutor] Confirmation if command worked

2011-08-24 Thread Christian Witts
iled error codes and abnormal termination to you. [1] http://support.attachmate.com/techdocs/2116.html [2] http://support.attachmate.com/techdocs/2487.html [3] http://support.attachmate.com/techdocs/2285.html [4] http://pexpect.sourceforge.net/pexpect.html -- Christian Witts Python Developer /

Re: [Tutor] Using Python to send signals to the USB port

2011-08-17 Thread Christian Witts
/listinfo/tutor Possibly look at the PyUSB module [1] and a tutorial on it [2]. Hopefully that helps and is enough for you. [1] http://sourceforge.net/apps/trac/pyusb/ [2] http://pyusb.sourceforge.net/docs/1.0/tutorial.html -- Christian Witts Python Developer

Re: [Tutor] Adding index numbers to tuple

2011-08-16 Thread Christian Witts
gt;> from itertools import chain >>> list(chain.from_iterable(new_t)) [0, 'a', 1, 'b', 2, 'c', 3, 'd'] That would be for if you were using the zip way, but enumerate should be simpler as Martin pointed out. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] "Object designer" applications - are there any?

2011-08-05 Thread Christian Witts
-commands [3] http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python scripts into executable Windows programss

2011-08-02 Thread Christian Witts
listed as Py2.5 64bit. http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/ -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How do I learn python for web development

2011-07-31 Thread Christian Witts
pment Beginner's Guide http://www.packtpub.com/python-3-web-development-beginners-guide/book It's Python 3.x, CherryPy, jQuery, jQuery UI -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@python.org To unsubscribe or chan

Re: [Tutor] Limit raw_input to hundredth decimal point

2011-07-01 Thread Christian Witts
st scan your input 1 character at a time and as soon as a the `.` is used you can limit it to 2 further key-strokes before you "ban" input and carry on in your process flow. -- Christian Witts Python Developer // ___ Tutor maillist - Tutor@pytho

Re: [Tutor] set the BETWEEN range in the SQL query using the python datetime function

2011-06-24 Thread Christian Witts
total_commission)), TypeError: not all arguments converted during string formatting what am i missing? thanks norman You've got 'Google AdWords - %s GBP' with no arguments and 'Commission - %s GBP' with 2 arguments. -- Christian Witts Python Developer // _

Re: [Tutor] floats

2011-06-06 Thread Christian Witts
t;> 100//1000 0 So you can still get the old behaving floor division using double divisors and any normal syntax will be true division. In Python 3.x it's already the standard, this is only necessary for Python 2.x -- Christian Witts // _

Re: [Tutor] python scripting using "./"

2011-05-24 Thread Christian Witts
or Where is the python binary actually located ? You can check with `which python` to find the location, mine was always /usr/bin/python with *nix, can't say off-hand the location with Mac. -- Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Christian Witts
On 2011/05/20 01:29 PM, Christian Witts wrote: On 2011/05/20 01:09 PM, Ganesh Kumar wrote: Hi Gurus, I am new python programming.. I see many programs if __name__ == '__main__': when I check __name__ always eq __main__. what purpose use these structure.. please guide me.. -Ganesh

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Christian Witts
script.py the __name__ will be __main__ but if you import it it's the name of the file. #first.py print __name__ #second.py import first $ python first.py __main__ $ python second.py first -- Christian Witts ___ Tutor maillist - Tuto

Re: [Tutor] Help needed

2011-04-08 Thread Christian Witts
k line at the bottom. I have tried to end it with main() but it errors on the main as well? Help Please, Aaron Brown ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tu

Re: [Tutor] Splitting a string

2011-02-08 Thread Christian Witts
On 08/02/2011 15:38, David Hutto wrote: On Tue, Feb 8, 2011 at 8:36 AM, Christian Witts wrote: On 08/02/2011 15:04, tee chwee liong wrote: hi all, thanks for the advice. i modified my code to be: c=('01101') i=-1 try: while 1: i=c.index('0',i+1)

Re: [Tutor] Splitting a string

2011-02-08 Thread Christian Witts
to be: >>> Lane fail 0 Lane fail 3 thanks tcl76 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor `while i < len(c)` instead of `while 1` -- Kind Regards, Christian Witts ___

Re: [Tutor] Splitting a string

2011-02-08 Thread Christian Witts
criteria, it only returns the first within your parameters, but you can create your own function utilising it to return all occurrences. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Christian Witts
poor English. > > > Best regards, > Tom > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > If I knew the input to

Re: [Tutor] turn a path into nested list

2011-01-13 Thread Christian Witts
man/listinfo/tutor First split your path into segments, then iterate over those segments and build your new list (item one being the current segment, and part two a joined string of previous segments). -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] cx_Oracle help

2011-01-05 Thread Christian Witts
___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor You need to install the Runtime, 3rd product option in the Oracle Universal Installer. -- Kind Regards, Christian Witts ___ Tutor

Re: [Tutor] doing maths on lists

2010-12-20 Thread Christian Witts
generate the answers and then sum it up. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Grabbing Info from Text files?

2010-11-12 Thread Christian Witts
7;test.conf'] >>> cfg.items('Blah') [('optone', '1'), ('optthree', '3'), ('opttwo', '2')] The other way to do it yourself is to iterate over the lines in the file, split the key and value and store it in a diction

Re: [Tutor] True Random Numbers

2010-11-02 Thread Christian Witts
Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error so you should be doing `from urllib.request import urlopen`.| -- Kin

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-21 Thread Christian Witts
rate over the results from your function in order to divide it into the 4 variables on the left-hand side. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Using contents of a document to change file names, (was Re: how to extract data only after a certain ...)

2010-10-11 Thread Christian Witts
and just iterate over it (that way there is only 1 line at a time stored in memory and you're not reading in the entire file first). It's not a Mac problem, just a problem with how you were going about it. Hope that helps. -- Kind Regards, Christian Witts

Re: [Tutor] trouble with list.remove() loop

2010-09-28 Thread Christian Witts
t you are iterating over so in essence you are looking at the word in list index 0, testing it, and removing it, then moving onto list index 1 but now your list has 'amazing' in index 0 so that does not get checked. The simplest way is to iterate through a new list with this for w

Re: [Tutor] wx to convert Group 4 Tifs to Gifs

2010-08-26 Thread Christian Witts
2 step conversion is tif -> gif seems to only give you access to the first page. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] why does this fail

2010-08-25 Thread Christian Witts
ction is just for learning purposes because there's a built-in string function you can use called replace and you'd use it as such `'apple'.replace('a', '')`. PS: Once you've gotten it to work convert it to a list comprehension, they are incredibly useful and a great tool. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Getting confusing NameError

2010-08-18 Thread Christian Witts
ry/functions.html#input [2] http://docs.python.org/library/functions.html#raw_input Hope that helps. Welcome to the list and enjoy your stay. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] FTP from mainframe

2010-07-29 Thread Christian Witts
on.org/mailman/listinfo/tutor When I'm retrieving items I use retrbinary for eg. from ftplib import FTP ftp = FTP(url, username, password) for filename in ftp.nlst(''): ftp.retrbinary('RETR %s' % filename, open(filename, 'wb').write) ftp.delete(fil

Re: [Tutor] position of an element in list:

2010-07-23 Thread Christian Witts
;) which would return 4. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] SQLite database locked problem

2010-07-19 Thread Christian Witts
tutor SQLite is technically thread safe, but a write operation locks the entire database [1]: - Any resultset being step()'d through uses a shared read-only lock. - Any insert/update being executed requires an exclusive write lock. [1] http://www.sqlite.org/lockingv3.html -- Kin

Re: [Tutor] Handling 'None' (null) values when processing sqlite cursorresults

2010-07-14 Thread Christian Witts
On 14/07/2010 19:34, Alan Gauld wrote: "Christian Witts" wrote You need a display function that can strip out the nulls as needed. A simple list comprehension or generator expression would work in this case: print ' '.join(str(field) for field in data if field

Re: [Tutor] Handling 'None' (null) values when processing sqlite cursorresults

2010-07-14 Thread Christian Witts
need a display function that can strip out the nulls as needed. A simple list comprehension or generator expression would work in this case: print ' '.join(str(field) for field in data if field is not 'None') The problem with that is i

Re: [Tutor] Time

2010-06-22 Thread Christian Witts
nsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor You can take a look at the timeit module [1] and some nice examples [2]. [1] http://docs.python.org/library/timeit.html [2] http://www.doughellmann.com/PyMOTW/timeit/ -- Kind Regards, Chris

Re: [Tutor] conventions for establishing and saving default values for variables

2010-06-15 Thread Christian Witts
n('PATH') cfg.set('PATH', 'workspace', work_path) f = open('options.cfg', 'w') cfg.write(f) f.close() else: work_path = cfg.get('PATH', 'workspace') -- Kind Regards, Christian Witts __

Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Christian Witts
ns: http://mail.python.org/mailman/listinfo/tutor The Python 3.x series changed the print statement to a print function. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Different between pass & continue

2010-05-18 Thread Christian Witts
gards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Any

2010-04-29 Thread Christian Witts
uggestions? Kevin Kirton Australia ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Maybe look through projects at Freshmeat [1]. [1] http://freshmeat.net/tags/python -

Re: [Tutor] Binary search question

2010-04-23 Thread Christian Witts
er than your target then bisect the bottom half of the list and check that and then it's a matter of rinse & repeat. You'll be suprised how few bisections you will need to do in order to find your data. -- Kind Regards, Christian Witts

Re: [Tutor] Loop comparison

2010-04-16 Thread Christian Witts
Dave Angel wrote: Christian Witts wrote: Ark wrote: Hi everyone. A friend of mine suggested me to do the next experiment in python and Java. It's a simple program to sum all the numbers from 0 to 10. result = i = 0 while i < 10: result += i i += 1 prin

Re: [Tutor] Loop comparison

2010-04-16 Thread Christian Witts
t I wouldn't expect the compiler optimiser to be that clever) The precalculation optimisations are taking place. If you pass it an argument to use for the upper limit of the sequence the calculation time shoots up. -- Kind Regards, Christian Witts

Re: [Tutor] Loop comparison

2010-04-16 Thread Christian Witts
0) Time taken: 7.15255737305e-06 450000 >>> t3(1999) Time taken: 0.003816121 1997001 >>> t4(1999) Time taken: 3.09944152832e-06 1996002 >>> t5(1999) Time taken: 3.09944152832e-06 1997001 -- Kind Regards, Christian Witts Business Intelligence C o m p

Re: [Tutor] Extracting lines in a file

2010-04-06 Thread Christian Witts
use the linecache module to get any line from any file for eg. >>> import linecache >>> linecache.getline('/etc/passwd', 4) 'sys:x:3:3:sys:/dev:/bin/sh\n' If what you require is more complex than simply that then you might be b

Re: [Tutor] characters

2010-03-30 Thread Christian Witts
Shurui Liu (Aaron Liu) wrote: In Python, could space be counted as a character same as a letter? len(...) len(object) -> integer Return the number of items of a sequence or mapping. As a space is an item it will be counted. -- Kind Regards, Christian Wi

Re: [Tutor] help

2010-03-30 Thread Christian Witts
again.. On Tue, Mar 30, 2010 at 4:55 PM, Christian Witts mailto:cwi...@compuscan.co.za>> wrote: Forwarding to the list. Martijn wrote: On Tue, Mar 30, 2010 at 12:15 PM, Christian Witts mailto:cwi...@compuscan.co.za> <mailto:cwi...@compuscan.co.za

Re: [Tutor] help

2010-03-30 Thread Christian Witts
Forwarding to the list. Martijn wrote: On Tue, Mar 30, 2010 at 12:15 PM, Christian Witts mailto:cwi...@compuscan.co.za>> wrote: Oshan Modi wrote: i am only a novice and just started programming.. i am having trouble running a .py file in the command promp

Re: [Tutor] help

2010-03-30 Thread Christian Witts
d work. -- Kind Regards, Christian Witts ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] trouble with dates and python and databases

2010-03-11 Thread Christian Witts
ase using SYSDATE you will need to call `trunc` on your log_date field in order for it to match your input. If for example you want the last 3 days of data though to trend on you can always do your select like select log_date, usage, capacity fromlogs where log_date >= trunc(sysd

  1   2   >