Re: how to determine Operating System in Use?
On Dec 13, 6:32 pm, "Ian F. Hood" <[EMAIL PROTECTED]> wrote: > Hi > In typically windows environments I have used: > if 'Windows' in os.environ['OS']... > to prove it, but now I need to properly support different environments. > To do so I must accurately determine what system the python instance is > running on (linux, win, mac, etc). > Is there a best practises way to do this? > TIA > Ian I would do this: if os.name == ''posix': linuxStuff() elif os.name == 'nt': windowsStuff() elif os.name == 'os2': ... --- os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos' -N -- http://mail.python.org/mailman/listinfo/python-list
Re: New to Python
On Mar 12, 4:49 am, "Bert Heymans" <[EMAIL PROTECTED]> wrote: > On Mar 12, 3:02 am, Alberto Vieira Ferreira Monteiro > > <[EMAIL PROTECTED]> wrote: > > Hi, I am new to Python, how stupid can be the questions I ask? > > > For example, how can I add (mathematically) two tuples? > > x = (1,2) > > y = (3,4) > > How can I get z = (1 + 3, 2 + 4) ? > > > Alberto Monteiro > > Alberto - > > List comprehesion, no doubt about it:>>> z = [k+p for k,p in (x, y)] To put the correct form of the soulution here. This will give the desired output z = [k+p for k,p in zip(x, y)] Or z = [k+p for k,p in map(None, x, y)] >>> z [4, 6] -N -- http://mail.python.org/mailman/listinfo/python-list
Re: call to function by text variable
On Mar 25, 6:36 pm, "ianaré" <[EMAIL PROTECTED]> wrote: > yeah the subject doesn't really make sense does it? > > anyway want I want to do is this: > if n == 1: > > self.operations.insert(pos, operations.Replace.Panel(self, main)) > > elif n == 2: > > self.operations.insert(pos, operations.ChangeCase.Panel(self, > main)) > > elif n == 3: > > self.operations.insert(pos, operations.Move.Panel(self, main)) > > As you can see all the different functions have the same variables, so > it would be easier if I could just make a list and use that. > > like this: > > list = ["Replace", "ChangeCase", "Move"] > textVariable = list[n] > self.operations.insert(pos, operations.[textVariable].Panel(self, > main)) try this one: textVariable = list[n-1] exec( "self.operations.insert(pos, operations.%s.Panel(self, main))" % textVariable ) Not sure if this is an elegant/right way. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with getting an option value
On Apr 10, 10:23 am, "Lucas Malor" <[EMAIL PROTECTED]> wrote: > Peter Otten wrote: > > Lucas Malor wrote: > > >> The problem is options is an instance, so options."delete", for example, > >> is wrong; I should pass options.delete . How can I do? > > > Use getattr(): > > Thank you. Do you know also if I can do a similar operation with functions? I > want to select with a string a certain get() function of ConfigParser: > > if type == "int" : > funcname = "getint" > elif type == "bool" : > funcname = "getboolean" > etc. > > How can I invoke the funcion with its name in a string? Use exec to assign to a variable. >>> def testPrint(msg): ...print 'Msg: %s' % msg ... >>> sfunc = "testPrint" >>> exec("f = %s" % sfunc) >>> f('Hello Python') Msg: Hello Python & use 'f = self.%s' % name for class methods. Hope its not a bad practice! -- http://mail.python.org/mailman/listinfo/python-list
Re: getopt with negative numbers?
On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote: ... > >>> args > > ['-123'] > > Without the "--" arg you will get an error: > > >>> parser.parse_args(["-123"]) > > Usage: [options] > > : error: no such option: -1 > $ > > Peter Passing -a-123 works >>> options, args = parser.parse_args(["-a-123"]) >>> options.a -123 -N -- http://mail.python.org/mailman/listinfo/python-list
Re: for v in l:
Try: l = [i+x for i in l] OR l = map(lambda i: i+x, l) -N Gert Cuykens wrote: > is there a other way then this to loop trough a list and change the values > > i=-1 > for v in l: > i=i+1 > l[i]=v+x > > something like > > for v in l: > l[v]=l[v]+x -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't find module named 'svn' in python
My first thought: Check if you have /usr/local/lib/svn-python/ in your PYTHONPATH environment variable (echo $PYTHONPATH). If its missing, set it in the environment. export PYTHONPATH=$PYTHONPATH:/usr/local/lib/svn-python -N [EMAIL PROTECTED] wrote: > Hi, > > i have a simple test which tries to load 'svn' moddule. > > # python -c "from svn import client" > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named svn > > I have checked I have sub-directories 'libsvn', 'svn' under > /usr/local/lib/svn-python/ > > cd /usr/local/lib/svn-python/ > [EMAIL PROTECTED] svn-python]# ls > libsvn svn > > But python still can't find it. Please tell me what am I missing. I > appreciate your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: instancemethod
> > if __name__ == '__main__': > gert=Db('localhost','root','**','gert') > gert.excecute('select * from person') > for x in range(0,gert.rowcount): > print gert.fetchone() > gert.close() > > [EMAIL PROTECTED]:~$ python ./Desktop/svn/db/Py/db.py > Traceback (most recent call last): > File "./Desktop/svn/db/Py/db.py", line 35, in > for x in range(0,gert.rowcount): > TypeError: range() integer end argument expected, got instancemethod. > [EMAIL PROTECTED]:~$ > > Can anybody explain what i must do in order to get integer instead of > a instance ? Gert, > for x in range(0,gert.rowcount): gert.rowcount is the method (and not a data attribute). gert.rowcount() is the method call, which get the return value from method. So try this. for x in range( 0,gert.rowcount() ): -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there sprintf in Python???
> Are there any sprintf in Python? Refer module StringIO - just like file input/output operations. cStringIO is another module (faster) Quick intro: from StringIO import StringIO s = StringIO() s.write('hello') s.seek(0) print s.read() -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting to an SSH account over a HTTP proxy
BJörn Lindqvist wrote: > I want to use Python to connect to a SSH account over a HTTP proxy to > automate some operations. I thought paramiko would be able to do that, > but it can not (it seems). > > Is there some other Python module that can do what I want? > > -- > mvh Björn Did you take a look at twisted library? twistedmatrix.com http://twistedmatrix.com/projects/core/documentation/howto/clients.html I haven't tried to connect over port 80, but its worth a try. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting to an SSH account over a HTTP proxy
> problem. I do not want to create my own SSH client and, AFAICT, there > is no SSH client in Twisted. The library also seem to have some > problems with handling HTTP proxies in a transparent > way:http://twistedmatrix.com/trac/ticket/1774 > > -- > mvh Björn There is a ssh implementation in twisted. http://twistedmatrix.com/users/z3p/files/conch-talk.html Are you able to authenticate and run commands using a ssh client on port 80? I will try to post an example if possible. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does producer delay halt shell pipe?
On Dec 11, 1:05 pm, dwhall <[EMAIL PROTECTED]> wrote: > filters. Is there any way to write the filter to make this work? > > thanks, > > !!Dean turn off python buffering & it should work. export PYTHONUNBUFFERED=t n'joy -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question on Classes
On Jan 10, 4:46 pm, "Adrian Wood" <[EMAIL PROTECTED]> wrote: > Hi al! I'm new to the list, and reasonably new to Python, so be gentle. > > Long story short, I'm having a hard time finding a way to call a > function on every object of a class at once. Example: > > I have a class Person, which has a function state(). This prints a > basic string about the Person (position, for example). In the program, > I have created two objects of class Person, called man and woman. > > I can call man.state() and then woman.state() or Person.state(man) and > Person.state(woman) to print the status of each. This takes time and > space however, and becomes unmanageable if we start talking about a > large number of objects, and unworkable if there is an unknown number. > What I'm after is a way to call the status of every instance of Man, > without knowing their exact names or number. > > I've gone through the relevant parts of the online docs, tried to find > information elsewhere online, and looked for code samples, but the > ionformation either isn't there, or just isn't clicking with me. I've > tried tracking the names of each object in a list, and even creating > each object within a list, but don't seem to be able to find the right > syntax to make it all work. > > I'd appreciate anyone who could help, especially if they could include > a short sample. My apologies if I'm not following the etiquette of the > group in some way my making this request. > > Thank you, > Adrian Hi Adrian, One easy way, is to append the objects to a list, as you have mentioned and call the state method in iteration. l = [] l.append(man) l.append(woman) # Print the state. for item in l: print item.state() (If I understood right, man and woman qualifies as "every instance of man") -N -- http://mail.python.org/mailman/listinfo/python-list
Re: split parameter line with quotes
On Jan 11, 1:50 pm, teddyber <[EMAIL PROTECTED]> wrote: > Hello, > > first i'm a newbie to python (but i searched the Internet i swear). > i'm looking for some way to split up a string into a list of pairs > 'key=value'. This code should be able to handle this particular > example string : > > qop="auth,auth-int,auth-conf",cipher="rc4-40,rc4-56,rc4,des, > 3des",maxbuf=1024,charset=utf-8,algorithm=md5-sess > > i know i can do that with some regexp (i'm currently trying to learn > that) but if there's some other way... > > thanks This is unconventional and using eval is not SAFE too. >>> s = >>> 'qop="auth,auth-int,auth-conf",cipher="rc4-40,rc4-56,rc4,des,3des",maxbuf=1024,charset="utf-8",algorithm="md5-sess"' >>> d = eval(' dict(%s)' % s) >>> d.items() [('algorithm', 'md5-sess'), ('maxbuf', 1024), ('charset', 'utf-8'), ('cipher', 'rc4-40,rc4-56,rc4,des,3des'), ('qop', 'auth,auth-int,auth- conf')] >>> for k,v in d.iteritems(): print k, '=', v ... algorithm = md5-sess maxbuf = 1024 charset = utf-8 cipher = rc4-40,rc4-56,rc4,des,3des qop = auth,auth-int,auth-conf For safe eval, take a look at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469 -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question on Classes
On Jan 10, 5:32 pm, "Steven Clark" <[EMAIL PROTECTED]> wrote: > > l = [] > > l.append(man) > > l.append(woman) > > > # Print the state. > > for item in l: > > print item.state() > > Small, off-topic nitpick: > please don't use "l" (lower-case el) as a variable name. > > >Fromhttp://www.python.org/dev/peps/pep-0008/: > > "Naming Conventions > > Names to Avoid > > Never use the characters `l' (lowercase letter el), `O' (uppercase > letter oh), or `I' (uppercase letter eye) as single character variable > names. > > In some fonts, these characters are indistinguishable from the numerals > one and zero. When tempted to use `l', use `L' instead." Thanks for the PEP, Steven. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: _struct in Python 2.5.2
On Feb 24, 10:39 am, Olaf Schwarz <[EMAIL PROTECTED]> wrote: > Hi, > > I am trying to run this > applicationhttp://svn.navi.cx/misc/trunk/python/bemused/ > on uNSLUng Linux 6.10 using the optware python packages. > > As I obtained segmentation faults using Python 2.4, I have upgraded to > 2.5.2. Now the execution terminates a lot earlier with this error > message: > > File "/usr/local/bemused_mpd/bemused-mpd.py", line 33, in > import bemused > File "/usr/local/bemused_mpd/bemused.py", line 27, in > import bluetooth, syslog > File "/opt/lib/python2.5/site-packages/bluetooth.py", line 2, in > > import struct > File "/opt/lib/python2.5/struct.py", line 30, in > from _struct import Struct, error > ImportError: No module named _struct > > I found out that there has been a file named _struct.so in 2.5.1 but > it has disappeared in 2.5.2. With no package available for downgrading > to 2.5.1 and no idea how to resolve this I am stuck at this point. > > Any help appreciated. > > Thank you > Olaf Hi Olaf, If you are still stuck, run ./configure make make install if you skip the command make, then the required files (lib/python2.5/lib-dynload/_struct.so) doesn't get created. Get the latest 2.5.2 rpm from python.org, it works. Good luck. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: sympy: what's wrong with this picture?
On Mar 3, 3:40 pm, Mensanator <[EMAIL PROTECTED]> wrote: > Notice anything funny about the "random" choices? > > import sympy > import time > import random > > f = [i for i in sympy.primerange(1000,1)] > > for i in xrange(10): > f1 = random.choice(f) > print f1, > f2 = random.choice(f) > print f2, > C = f1*f2 > ff = None > ff = sympy.factorint(C) > print ff > > ## 7307 7243 [(7243, 1), (7307, 1)] > ## 4091 6829 [(4091, 1), (6829, 1)] > ## 8563 2677 [(2677, 1), (8563, 1)] > ## 4091 6829 [(4091, 1), (6829, 1)] > ## 8563 2677 [(2677, 1), (8563, 1)] > ## 4091 6829 [(4091, 1), (6829, 1)] > ## 8563 2677 [(2677, 1), (8563, 1)] > ## 4091 6829 [(4091, 1), (6829, 1)] > ## 8563 2677 [(2677, 1), (8563, 1)] > ## 4091 6829 [(4091, 1), (6829, 1)] > > As in, "they're NOT random". > > The random number generator is broken by the sympy.factorint() > function. > > Random.choice() works ok if the factorint() function commented out. > > ## 6089 1811 None > ## 6449 1759 None > ## 9923 4639 None > ## 4013 4889 None > ## 4349 2029 None > ## 6703 8677 None > ## 1879 1867 None > ## 5153 5279 None > ## 2011 4937 None > ## 7253 5507 None > > This makes sympy worse than worthless, as it fucks up other modules. Does seeding ( random.seed ) random with time fix this? It should. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode box drawing
On Mar 4, 12:51 pm, jefm <[EMAIL PROTECTED]> wrote: > How can I print the unicode box drawing characters in python: > > print u'\u2500' > print u'\u2501' > print u'\u2502' > print u'\u2503' > print u'\u2504' > > Traceback (most recent call last): > File "\test.py", line 3, in ? > print u'\u2500' > File "C:\Python24\lib\encodings\cp1252.py", line 18, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode character u'\u2500' > in position 0: character maps to Just FYI, not an answer. It works like a charm on linux (ubuntu, fc3, python 2.4.1 & 2.5.2) Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print u'\u2500' ─ >>> print u'\u2501' ━ >>> print u'\u2502' │ >>> print u'\u2503' ┃ >>> >>> print u'\u2504' ┄ on windows using python 2.4. ??? -N -- http://mail.python.org/mailman/listinfo/python-list
Re: sympy: what's wrong with this picture?
On Mar 4, 3:13 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Mar 4, 12:32 pm, Nanjundi <[EMAIL PROTECTED]> wrote: > > > > Does seeding ( random.seed ) random with time fix this? It should. > > I suppose that depends on how long it takes factorint() to > process a number. If the seed is reset before the next clock > tick, you will get the same random numbers as the previous > iteration. Alright, then make it constant and don't worry about the clock tick. >>> for i in xrange(10): ... f1 = random.choice(f) ... print f1, ... f2 = random.choice(f) ... print f2, ... C = f1*f2 ... ff = None ... ff = sympy.factorint(C) ... print ff ... random.seed(i) ... 5573 5171 [(5171, 1), (5573, 1)] 8537 7673 [(7673, 1), (8537, 1)] 2063 8573 [(2063, 1), (8573, 1)] 9551 9473 [(9473, 1), (9551, 1)] 2909 5659 [(2909, 1), (5659, 1)] 2897 1789 [(1789, 1), (2897, 1)] 6361 7541 [(6361, 1), (7541, 1)] 8017 8293 [(8017, 1), (8293, 1)] 3671 2207 [(2207, 1), (3671, 1)] 2803 9629 [(2803, 1), (9629, 1)] > Frankly, I don't understand why factorint() reseeds at all. Read the doc: *The rho algorithm is a Monte Carlo method whose outcome can be affected by changing the random seed value. * > Doesn't Random automatically initialize the seed? > Doesn't constantly reseeding degrade the performance of the > random number generator? With Robert Kern's patch, the reseeding > is no longer a constant, fixing the immediate symptom. Does it matter? The factorint reseeds using a constant seed (1234). > > But what if _I_ wanted to make a repeatable sequence for test > purposes? Wouldn't factorint() destroy my attempt by reseeding > on every call? Repeatable sequence? save it and reuse! Think about "What if"s doesn't get any work done. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: sympy: what's wrong with this picture?
On Mar 5, 3:34 pm, Mensanator <[EMAIL PROTECTED]> wrote: > On Mar 5, 9:29 am, Nanjundi <[EMAIL PROTECTED]> wrote: > > > On Mar 4, 3:13 pm, Mensanator <[EMAIL PROTECTED]> wrote: > > > > On Mar 4, 12:32 pm, Nanjundi <[EMAIL PROTECTED]> wrote: > > > > > Does seeding ( random.seed ) random with time fix this? It should. > > > > I suppose that depends on how long it takes factorint() to > > > process a number. If the seed is reset before the next clock > > > tick, you will get the same random numbers as the previous > > > iteration. > > > Alright, then make it constant and don't worry about the clock tick. > > Reseeding with a constant always sets the sequence to the same > starting > point. > Right, not a good idea. > > > >>> for i in xrange(10): > > > ... f1 = random.choice(f) > > ... print f1, > > ... f2 = random.choice(f) > > ... print f2, > > ... C = f1*f2 > > ... ff = None > > ... ff = sympy.factorint(C) > > ... print ff > > ... random.seed(i) > > ... > > 5573 5171 [(5171, 1), (5573, 1)] > > 8537 7673 [(7673, 1), (8537, 1)] > > 2063 8573 [(2063, 1), (8573, 1)] > > 9551 9473 [(9473, 1), (9551, 1)] > > 2909 5659 [(2909, 1), (5659, 1)] > > 2897 1789 [(1789, 1), (2897, 1)] > > 6361 7541 [(6361, 1), (7541, 1)] > > 8017 8293 [(8017, 1), (8293, 1)] > > 3671 2207 [(2207, 1), (3671, 1)] > > 2803 9629 [(2803, 1), (9629, 1)] > > > > Frankly, I don't understand why factorint() reseeds at all. > > > Read the doc: > > *The rho algorithm is a Monte Carlo method whose outcome can be > > affected by changing the random seed value. * > > But that doesn't give it the right to mess with the state > of the random number generator _I'm_ using. Had I actually > known what was happening, I could have saved the state of > my random number generator s=random.getstate() and then restored > it after calling factorint(), random.setstate(s). > > import sympy # with RK's patch removed > import time > import random > > f = [i for i in sympy.primerange(1000,1)] > > for i in xrange(10): > f1 = random.choice(f) > print f1, > f2 = random.choice(f) > print f2, > C = f1*f2 > ff = None > rs = random.getstate() > ff = sympy.factorint(C) > random.setstate(rs) > print ff > > 5669 3863 [(3863, 1), (5669, 1)] > 1973 5431 [(1973, 1), (5431, 1)] > 7577 6089 [(6089, 1), (7577, 1)] > 8761 4957 [(4957, 1), (8761, 1)] > 4153 2719 [(2719, 1), (4153, 1)] > 4999 5669 [(4999, 1), (5669, 1)] > 8863 5417 [(5417, 1), (8863, 1)] > 7151 7951 [(7151, 1), (7951, 1)] > 7867 9887 [(7867, 1), (9887, 1)] > 9283 5227 [(5227, 1), (9283, 1)] > > Of course, this is new as of Python 2.4, so if factorint() > tried to save & restore state, sympy wouldn't work on Python > 2.3 or earlier. > > If I'm reading RK's patch correctly, he doesn't reseed the > random number generator, he creates a new random object that > maintains it's own state that can be freely seeded to any > value without disturbing the state of my random number generator. > > > > > > Doesn't Random automatically initialize the seed? > > > Doesn't constantly reseeding degrade the performance of the > > > random number generator? With Robert Kern's patch, the reseeding > > > is no longer a constant, fixing the immediate symptom. > > > Does it matter? > > I was wrong. It is a constant, just not 1234. If that's what > factorint() needs, fine. As long as it maintains a seperate state > than the one I'm using. > > > The factorint reseeds using a constant seed (1234). > > Not now it doesn't: :) > > @@ -92,8 +92,8 @@ def pollard_pm1(n, B=10, seed=1234): > > """ > from math import log > -random.seed(seed + B) > -a = random.randint(2, n-1) > +prng = random.Random(seed + B) > +a = prng.randint(2, n-1) > for p in sieve.primerange(2, B): > e = int(log(B, p)) > a = pow(a, p**e, n) > > > > > > But what if _I_ wanted to make a repeatable sequence for test > > > purposes? Wouldn't factorint() destroy my attempt by reseeding > > > on every call? > > > Repeatable sequence? save it and reuse! > > As part of my resolution to tone down my attitude, > I won't even reply to that. > Thanks. > > Think about "What if"s doesn't get any work done. > > ? nevermind. > > > > > -N -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested try...except
On Apr 2, 9:22 am, [EMAIL PROTECTED] wrote: > On 2 Apr, 15:15, [EMAIL PROTECTED] wrote: > > > > > On 2 Apr, 15:12, [EMAIL PROTECTED] wrote: > > > > On Apr 2, 3:06 pm, [EMAIL PROTECTED] wrote: > > > > > Hi, > > > > > I found the following code on the net - > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/[EMAIL > > > > PROTECTED] > > > > > def count(self): > > > > -db = sqlite.connect(self.filename, > > > > isolation_level=ISOLATION_LEVEL) > > > > -try: > > > > -try: > > > > -cur = db.cursor() > > > > -cur.execute("select count(*) from sessions") > > > > -return cur.fetchone()[0] > > > > -finally: > > > > -cur.close() > > > > -finally: > > > > -db.close() > > > > > I don't understand though why the second try is not after the line cur > > > > = db.cursor(). Can anyone explain for me why? > > > > > /Barry. > > > > Better question is why is there a try with no except... > > > > Better yet, WHY is there two TRY statements when there could quite > > > happily be only one... > > > > Towards what you are asking, I GUESS...because the author hoped to > > > handle the cases where cur failed to get assigned...but then > > > his .close method of it would likely not work anyway...I mean...does > > > this even work...YUCK > > > I shouldn't have written "Nested try...except" as the title, instead I > > mean "Nested try...finally". Sorry about that... > > > Anyway, how would you do this? That is, use a finally to close the > > network connection and the cursor? > > > Thanks for your help, > > > Barry > > Here's what I would do. Is it OK? > > def ExecuteWithNoFetching(self, queryString): > > sqlServerConnection = adodbapi.connect (";".join (connectors)) > try: > cursor = sqlServerConnection.cursor() > try: > cursor.execute(queryString) > raise Exception("Exception") > sqlServerConnection.commit() > finally: > cursor.close() > finally: > sqlServerConnection.close() No.. Why do you have raise statement? "sqlServerConnection.commit()" never gets executed. -N -- http://mail.python.org/mailman/listinfo/python-list
Re: () vs []
On Oct 14, 1:05 pm, mattia wrote: > Any particular difference in using for a simple collection of element () > over [] or vice-versa? > > Thanks, Mattia From: http://www.faqs.org/docs/diveintopython/odbchelper_tuple.html 1 You can’t add elements to a tuple. Tuples have no append or extend method. 2 You can’t remove elements from a tuple. Tuples have no remove or pop method. 3 You can’t find elements in a tuple. Tuples have no index method. 4 You can, however, use in to see if an element exists in the tuple. So what are tuples good for? * Tuples are faster than lists. If you’re defining a constant set of values and all you’re ever going to do with it is iterate through it, use a tuple instead of a list. * Remember I said that dictionary keys can be integers, strings, and “a few other types”? Tuples are one of those types. Tuples can be used as keys in a dictionary, but lists can’t.[2] * Tuples are used in string formatting, as we’ll see shortly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Financial time series data
On Sep 2, 1:12 pm, Virgil Stokes wrote: > Has anyone written code or worked with Python software for downloading > financial time series data (e.g. from Yahoo financial)? If yes, would you > please contact me. > > --Thanks, > V. Stokes matplotlib has a finance module you can refer to. (matplotlib.finance.fetch_historical_yahoo) see the example: http://matplotlib.sourceforge.net/examples/pylab_examples/finance_work2.html -- http://mail.python.org/mailman/listinfo/python-list