Re: [Tutor] how to sort a tab delim file

2010-01-13 Thread vince spicer
On Wed, Jan 13, 2010 at 9:21 AM, Hs Hs wrote: > Hi: > > I have a tab-delim file: > > col1 col2 col3 > andrew1987 1990 > jake 1974 1980 > jim 1964 1970 > lance1984 1992 > > > how can I sort column 2 and get : > jim 1964 1970 > jake

Re: [Tutor] how to sort a tab delim file

2010-01-13 Thread vince spicer
On Wed, Jan 13, 2010 at 9:21 AM, Hs Hs wrote: > Hi: > > I have a tab-delim file: > > col1 col2 col3 > andrew1987 1990 > jake 1974 1980 > jim 1964 1970 > lance1984 1992 > > > how can I sort column 2 and get : > jim 1964 1970 > jake

Re: [Tutor] help with strings

2010-02-03 Thread vince spicer
On Wed, Feb 3, 2010 at 7:19 AM, NISA BALAKRISHNAN < snisa.balakrish...@gmail.com> wrote: > hi > > I am very new to python. > I have a string for example : 123B new Project > i want to separate 123B as a single string and new project as another > string . > how can i do that. > i tried using p

Re: [Tutor] html and python

2010-02-10 Thread vince spicer
On Wed, Feb 10, 2010 at 1:30 PM, Grigor Kolev wrote: > Hi. > I want to make a list of E-mail, photos and some additional data. > But I want this list to be displayed in one site. > How can I send data from a list of site page. Which module should I use > -- > Grigor Kolev > >

Re: [Tutor] html and python

2010-02-10 Thread vince spicer
On Wed, Feb 10, 2010 at 1:30 PM, Grigor Kolev wrote: > Hi. > I want to make a list of E-mail, photos and some additional data. > But I want this list to be displayed in one site. > How can I send data from a list of site page. Which module should I use > -- > Grigor Kolev > >

Re: [Tutor] Compile py to exe in ubuntu

2010-02-10 Thread vince spicer
On Wed, Feb 10, 2010 at 1:40 PM, Harya Dananjaya wrote: > Can I compile my python source to exe in ubuntu? > if I can do it, which compiler can do it? > > Thanks you, > > Harya Dananjaya > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or c

Re: [Tutor] test

2010-02-25 Thread vince spicer
On Thu, Feb 25, 2010 at 4:03 PM, Kirk Bailey wrote: > test > -- > > > Cheers! > -Kirk D Bailey > > THINK > +-+ > .*.| BOX | > ..*+-+ > *** THINK > ___ > Tutor maillist - Tutor@python.

Re: [Tutor] Append sub-key to dictionary

2010-05-25 Thread vince spicer
On Tue, May 25, 2010 at 12:28 PM, M. Bashir Al-Noimi wrote: > Hi All, > > I'm trying to append a new sub-key to specific dictionary but it replacing > the content of parent key instead of add a sub-key! > > > How I can fix this issue? > > --snippet-- > > addressbook = { >'work': {

Re: [Tutor] List comprehension for dicts?

2010-08-19 Thread Vince Spicer
Hey you can use list comprehension here age_dict = { 'pete': 42, 'ann': 25, 'carl': 30, 'amanda': 64 } you can create a dict from a list of tuples and you can access the dict as a list of tuples by accessing its items Example: age_dict = dict([(key.upper(), value) for key,value in age_dict.item

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

2010-09-13 Thread Vince Spicer
On Mon, Sep 13, 2010 at 9:58 PM, wrote: > Hi, > > I'm parsing IMDB movie reviews (each movie is in its own text file). In my > script, I'm trying to extract genre information. Movies have up to three > categories of genres--but not all have a "genre" tag and that fact is making > my script abort

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

2010-09-13 Thread Vince Spicer
on't choke if you don't find any rgenres > because rf.info["genre"] was empty". But maybe I need to define the "None" > condition earlier? > > Basically a text file has this structure: > > High Noon > Drama;Western # But this tag doesn't

Re: [Tutor] "Overloading" methods

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 6:02 AM, Michael Powe wrote: > Hello, > > Strictly speaking, this isn't overloading a method in the way we do it > in Java. But similar. Maybe. > > I am writing a module for processing web server log files and one of > the methods I provide is to extract a given query pa

Re: [Tutor] Comparing two lists

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > Hello, > > I have two lists. > > alist = ['label', 'guid'] > > blist = ['column0label', 'column1label', 'dimension0guid', > 'description', 'columnid'] > > I want to iterate over blist and extract the items that match my > substrings in alist

Re: [Tutor] Comparing two lists

2010-09-16 Thread Vince Spicer
On Thu, Sep 16, 2010 at 12:49 PM, Vince Spicer wrote: > > > On Thu, Sep 16, 2010 at 12:27 PM, Michael Powe wrote: > >> Hello, >> >> I have two lists. >> >> alist = ['label', 'guid'] >> >> blist = ['column0label&#x

Re: [Tutor] Getting/setting attributes

2010-09-21 Thread Vince Spicer
as __address but get rewritten to _Computer__address (so not private but not obvious) class Computer(object): def __init__(self): self.__address = None # see note on private vars in Python http://docs.python.org/tutorial/classes.html?highlight=private#private-variables @

Re: [Tutor] dynamic arrays?

2010-09-27 Thread Vince Spicer
line) #method 2: this will convert a file into an array data = open("file.txt", "r").readlines() #method 3: if you had to know the line number a = [] for i, line in enumerate(open('flie.txt')): print i, line a.append(line) Hope this helps -- Vince Spicer Lea

Re: [Tutor] Statistic-Program Problems! Please Help Quickly!

2010-10-15 Thread Vince Spicer
On Thu, Oct 14, 2010 at 10:11 PM, Colleen Glaeser wrote: > BTW, the error message my program gives me for the B and M functions is: > > Traceback (most recent call last): > File "I:\Lab 7 wierd stat data.py", line 49, in > B() > File "I:\Lab 7 wierd stat data.py", line 44, in B > > ((

Re: [Tutor] Requesting restricted URL (further authentication requested)

2010-10-19 Thread Vince Spicer
utor > Tim, Unless you are tied to the standard library I would recommend looking at httplib2 http://code.google.com/p/httplib2/ This handles your authentication and connection much better then the standard urllib. -- Vince Spicer -- Sent from Ubuntu __

Re: [Tutor] rights

2010-11-01 Thread Vince Spicer
python.org/mailman/listinfo/tutor > Which Operation System? In linux the user that is running the script must be have read access chmod +r folder -- Vince Spicer -- Sent from Ubuntu ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > Hello Chris You can manage you path from within your script, import sys sys.path.append("/home/user/lib") Or in bash you can edit your $PYTHONPATH env variable echo $PYTHO

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 3:58 PM, Chris King wrote: > On 11/1/2010 5:57 PM, Vince Spicer wrote: > > > > On Mon, Nov 1, 2010 at 3:54 PM, Chris King wrote: > >> On 11/1/2010 5:47 PM, Vince Spicer wrote: >> >> >> >> On Mon, Nov 1, 2010 at

Re: [Tutor] pythonpath

2010-11-01 Thread Vince Spicer
On Mon, Nov 1, 2010 at 4:00 PM, Vince Spicer wrote: > > > On Mon, Nov 1, 2010 at 3:58 PM, Chris King wrote: > >> On 11/1/2010 5:57 PM, Vince Spicer wrote: >> >> >> >> On Mon, Nov 1, 2010 at 3:54 PM, Chris King wrote: >> >>> On 11/1

Re: [Tutor] if statement

2010-11-02 Thread Vince Spicer
; > To unsubscribe or change subscription options: > > > http://mail.python.org/mailman/listinfo/tutor > > > > > > > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subsc

Re: [Tutor] Add newline's, wrap, a long string

2009-04-28 Thread vince spicer
first, grabbing output from an external command try: import commands USE = commands.getoutput('grep USE /tmp/comprookie2000/emege_info.txt |head -n1|cut -d\\"-f2') then you can wrap strings, import textwrap Lines = textwrap.wrap(USE, 80) # return a list so in short: import commands, textwrap

Re: [Tutor] Advanced String Search using operators AND, OR etc..

2009-05-04 Thread vince spicer
Advanced Strings searches are Regex via re module. EX: import re m = re.compile("(FDA.*?(approved|supported)|Ben[^\s])*") if m.search(Text): print m.search(Text).group() Vince On Mon, May 4, 2009 at 6:45 AM, Alex Feddor wrote: > Hi > > I am looking for method enables advanced text str

Re: [Tutor] Sorting a list

2009-05-13 Thread vince spicer
you can pass sort a custom compare function Simple ex: def compare(x,y): try: return cmp(int(x), int(y)) except: pass try: int(x) except: return -1 try: int(y) except: return 1 return 0 x = [4, 6, 'word', 3, 9] x.sort(

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread vince spicer
Take a peak at commands.getoutput EX: import commmands ls = commands.getoutput("ls- ls") Vince On Thu, May 14, 2009 at 3:50 PM, MK wrote: > Hi there, > > i am using this code to send an "cat > ThisIsMyUrl" with popen. > Of cos cat now waits for the CTRL+D command. > How can i send this comm

Re: [Tutor] Python popen command using cat > textfile .... how to terminate

2009-05-14 Thread vince spicer
import commands On Thu, May 14, 2009 at 4:28 PM, vince spicer wrote: > Take a peak at commands.getoutput > > > EX: > > import commmands > > ls = commands.getoutput("ls- ls") > > Vince > > > On Thu, May 14, 2009 at 3:50 PM, MK wrote: > >

Re: [Tutor] Allow only one instance of a process

2009-05-16 Thread Vince Spicer
simple solution would be to create a lock file before processing, lock = open("videoname.lck") lock.close() On Saturday 16 May 2009 8:26:31 pm Sylvain Ste-Marie wrote: > I'm currently writing a script to batch convert video for my psp > > It basically looks into a folder for video and launch

Re: [Tutor] web cam

2009-05-20 Thread vince spicer
I've seen this win32 library: http://videocapture.sourceforge.net via http://technobabbler.com?p=22 for linux http://www.antonym.org/libfg Vince 2009/5/20 Ricardo Aráoz > Hi, a friend of mine has asked me how difficult would it be to send web > cam images through python program as a hobby pr

Re: [Tutor] how to get variable from an external script or program

2009-05-29 Thread vince spicer
import commands output = commands.getout("ls -lah") Vince On Fri, May 29, 2009 at 3:27 PM, shawn bright wrote: > Hey all > > I have a small program that when run from the command line, will > return a certain value for an arguement. Like this: > > > mfetchz 45 > > 45j > > so the program is mfet

Re: [Tutor] how to get variable from an external script or program

2009-05-29 Thread vince spicer
Sorry *output import commands > output = commands.getoutput("ls -lah") > Vince > > > On Fri, May 29, 2009 at 3:27 PM, shawn bright wrote: > >> Hey all >> >> I have a small program that when run from the command line, will >> return a certain value for an arguement. Like this: >> >> > mfetchz 4

Re: [Tutor] How o convert spaces into tabs??

2009-06-02 Thread vince spicer
regex will do it import re line = re.sub(r"\s+", "\t", line) print line Vince On Tue, Jun 2, 2009 at 11:42 AM, jyotsna guleria wrote: > > Hello every one, > > I am trying to parse a file: > > I want to convert all the spaces in between the characters to single tab. > > e.g: my file has con

Re: [Tutor] improvement of if - else code

2009-06-04 Thread vince spicer
you could assign loop variable @staticmethod def get_form(address=None, postcode=None, town=None, phone=None, fax=None, freephone=None, address_country=None, address_region=None, address_county=None, hotel=None): context = get_context() root = co

Re: [Tutor] Simple factorial program

2009-06-11 Thread vince spicer
did you declare factorial before trying to use it? factorial = 1 print "Factorial finder" number = int(input("Please enter a non-negative integer: ")) for number in range(number, 1) factorial = (factorial * number) print "Factorial:", factorial On Thu, Jun 11, 2009 at 9:53 AM, Eddie wrote:

Re: [Tutor] Simple factorial program

2009-06-11 Thread vince spicer
no ":" after for statement Vince On Thu, Jun 11, 2009 at 10:06 AM, Eddie wrote: > Thanks, that is my problem. > > With that code, why is it giving an error (indenting?) at the end of* for > number in range(number, 1) *? > > 2009/6/12 vince spicer > > did y

Re: [Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

2009-06-17 Thread vince spicer
Like in any language there any number for ways, heres another b = "bottles of beer" w = "on the wall" bottles = range(1, 101) bottles.reverse() for bottle in bottles: print " %s %s %s if one of those bottles should happen to fall there'll be %s %s %s" % (bottle, b,w, bottle-1, b,w) Vince 200

Re: [Tutor] Handling Generator exceptions in Python 2.5

2009-06-19 Thread vince spicer
Well* *result = [(ListA[i] - ListB[i-1])/ListA[i] for i in range(len(ListA))*if not ListA[i] == 0*] will exclude any results where listA[i] is 0, if you still want these in the result you may want to use good'ol for statement instead of list comprehension results = [] for x in range(len(listA))

Re: [Tutor] extracting lines in large file

2009-06-22 Thread vince spicer
14mb file shouldn't be an issue, unless you very little ram, is there any errors being outputted? a cleaner way for reading the file: for line in open("output.new"): if line.startswith("intrinsic"): print line On Mon, Jun 22, 2009 at 2:16 PM, Bryan Fodness wrote: > I am trying to o

Re: [Tutor] extracting lines in large file

2009-06-22 Thread Vince Spicer
revious ones. > > On Mon, Jun 22, 2009 at 4:21 PM, vince spicer wrote: > > 14mb file shouldn't be an issue, unless you very little ram, is there any > > errors being outputted? > > > > a cleaner way for reading the file: > > > > for line in open(&q

Re: [Tutor] Trouble with passing commands / variables to os.system()

2009-06-23 Thread vince spicer
os.system is not the best way to handle this you may want to look into the subprocess module however: import os username = 'charlie' private_key = '/path/to/key' ssh = '/usr/bin/ssh' command = 'hostname && df -h && exit' servers = ['172.16.1.1', '172.16.12.2', '172.16.1.3'] for host in servers

Re: [Tutor] string pickling and sqlite blob'ing

2009-06-24 Thread vince spicer
Pickle is more for storing complex objects (arrays, dict, etc). pickling a string makes it bigger. I have stored large text chunks in text and/or blob columns compressed with gzip.zlib.compress and extracted with gzip.zlib.decompress Comparison: import cPickle as Pickle import gzip x = "asdfasd

Re: [Tutor] string pickling and sqlite blob'ing

2009-06-25 Thread vince spicer
erence whether it is stored it in a TEXT or BLOB column? > > Dinesh > > > > *From:* vince spicer > *Sent:* Wednesday, June 24, 2009 10:49 AM > *To:* Dinesh B Vadhia > *Cc:* tutor@python.org > *Subject:* Re: [Tutor] string pickling and sqlite blob'ing > >

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

2009-07-14 Thread vince spicer
First off, selenium is a great tool and the python driver is very powerful there are numerous ways to access cli variables, the quickest import sys print sys.srgv sys.argv will it output a array of all command line args ./selenium-google-test.py yankees will out put: ['selenium-google-test.py

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

2009-07-14 Thread vince spicer
le "/usr/lib/python2.6/unittest.py", line 849, in createTests >self.module) > File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames >suites = [self.loadTestsFromName(name, module) for name in names] > File "/usr/lib/python2.6/unitt

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

2009-07-15 Thread vince spicer
good catch, my mistake args[1] == 'yankees' True On Wed, Jul 15, 2009 at 12:25 AM, Christian Witts wrote: > vince spicer wrote: > >> First off, selenium is a great tool and the python driver is very powerful >> >> there are numerous ways to access cli variable

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
simple example of calling a class class myKlass(object): On Wed, Jul 15, 2009 at 6:33 AM, Kent Johnson wrote: > On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto wrote: > > Hi, > > > > Can some one give, or point to some good examples of how @decorators > work, and __call__ (able) objects? > >

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
simple example of calling a class class myKlass(object): def __call__(self, *args, **kws): print "i was called" >> test = myKlass() >> test() >> i was called > > > > On Wed, Jul 15, 2009 at 6:33 AM, Kent Johnson wrote: > >> On Wed, Jul 15, 2009 at 7:41 AM, Todd Matsumoto >> wr

Re: [Tutor] just one question

2009-07-15 Thread vince spicer
one way is: import re infile = open("test.txt", "r") #: open read mode outfile = open("out.tx", "w") #: open write mode for line in infile: values = re.split("\s+", line) # split values on spaces EX: ['47', '8', 'ALA', 'H', 'H', '7.85', '0.02', '1'] outfile.write("%s %s C = %s CA = %

Re: [Tutor] objects becoming pointers

2009-07-15 Thread vince spicer
not sure exactly why you would want to that, but you could assign attributes to a class EX: class storage: pass >> store = Storage() >> name=raw_input() >> setattr(store, name, zeros(3,3)) >> print store.Chris On Wed, Jul 15, 2009 at 9:19 AM, chris Hynes wrote: > I guess I have to sta

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread vince spicer
agreed much better description, thanks On Wed, Jul 15, 2009 at 1:02 PM, wesley chun wrote: > >>> > Can some one give, or point to some good examples of how @decorators > >>> > work, and __call__ (able) objects? > > > > simple example of calling a class > > > > class myKlass(object): > > > >

Re: [Tutor] decorators, __call__ (able) objects

2009-07-15 Thread Vince Spicer
s guys, > > In the example the __call__ method has *args and **kws as arguments. Is > that required? > > Also when, in what situation would you use callable objects? > > Cheers, > > T > Original-Nachricht > > > Datum: Wed, 15 Jul 2009 12:02

Re: [Tutor] dictionaries help

2009-07-23 Thread vince spicer
this should work def find_value(value, lst): for obj in lst: if value in obj.values(): return obj >> find_value("aaa", my_lst) Vince On Thu, Jul 23, 2009 at 9:55 AM, wrote: > hello, > please excuse me, but i would like to understand how dictionaris work. > > for examp

Re: [Tutor] traversing page and then following the link

2009-07-24 Thread vince spicer
there are many ways to parse html pages and retrieve data, I tend to use lxml and xpath to simplify things and urllib to pull down the data lxml is not a core library but can be installed via easy_install, the main benefit is the xpath support =

Re: [Tutor] Help with multiple substitution

2009-07-24 Thread vince spicer
not perfect or tested but import re chopset.reverse() #: put the longer extensions first exts = "|".join([re.escape(x) fro x in chopset)]) for line in file: print exts.sub("", line) On Fri, Jul 24, 2009 at 9:22 AM, vankayala sailakshman < sailakshm...@hotmail.com> wrote: > > Hi All, > >

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread vince spicer
you can build a dictionary and keep the active key, again this would only work in predictable data users = {} name = None for line in file: key, value = [x.strip() for x in line.split(":")] if key == "name": name = data[1] users[name] = {} else: users[name][d

Re: [Tutor] Web crawling!

2009-07-29 Thread vince spicer
On Wed, Jul 29, 2009 at 9:59 AM, Raj Medhekar wrote: > Does anyone know a good webcrawler that could be used in tandem with the > Beautiful soup parser to parse out specific elements from news sites like > BBC and CNN? Thanks! > -Raj > > > ___ > Tutor ma

Re: [Tutor] Issues with regex escaping on \{

2009-07-29 Thread vince spicer
On Wed, Jul 29, 2009 at 11:35 AM, gpo wrote: > > My regex is being run in both Python v2.6 and v3.1 > For this example, I'll give one line. This lines will be read out of log > files. I'm trying to get the GUID for the User ID to query a database with > it, so I'd like a sub match. Here is the

Re: [Tutor] Assigning each line of text to a separate variable

2009-07-30 Thread vince spicer
On Thu, Jul 30, 2009 at 1:19 PM, Marv Boyes wrote: > Hello, all. This is probably embarrassingly basic, but I haven't been able > to find something that works. > > I'm working on a script that needs to manipulate a list (not 'list' in the > Python sense) of URLs returned in a server response. Rig

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread vince spicer
On Thu, Aug 6, 2009 at 3:18 PM, chase pettet wrote: > I am trying to write a script to work our LVS implementation. I want to be > able to have user do something like this "./script SITE SERVER" and have > the script look up the ip value of the site on that server and issue the > command to pul

Re: [Tutor] Looking up a value in a dictionary from user input problem

2009-08-06 Thread vince spicer
On Thu, Aug 6, 2009 at 3:42 PM, vince spicer wrote: > > > On Thu, Aug 6, 2009 at 3:18 PM, chase pettet wrote: > >> I am trying to write a script to work our LVS implementation. I want to >> be able to have user do something like this "./script SITE SERVER"

Re: [Tutor] how to remove first '/'

2009-08-25 Thread vince spicer
On Tue, Aug 25, 2009 at 3:55 PM, wrote: > Hello, > I want to strip the first '/' from the following: > > '/path/to/file' > > How can I do this? > > Dave > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > there

Re: [Tutor] packing a list of lists

2009-08-28 Thread vince spicer
On Fri, Aug 28, 2009 at 8:05 AM, kevin parks wrote: > Back to python after a long long layoff. So i am running into some > beginner's confusion... > > I am trying to plot a list of numbers in gnuplot.py. To do that I am trying > to pack the list with an index by iterating over the list so i can g

Re: [Tutor] packing a list of lists

2009-08-28 Thread vince spicer
On Fri, Aug 28, 2009 at 9:18 AM, vince spicer wrote: > > > On Fri, Aug 28, 2009 at 8:05 AM, kevin parks wrote: > >> Back to python after a long long layoff. So i am running into some >> beginner's confusion... >> >> I am trying to plot a list of numbers

Re: [Tutor] packing a list of lists

2009-08-28 Thread vince spicer
On Fri, Aug 28, 2009 at 10:49 AM, kevin parks wrote: > > Thanks for the replies. Though the list comprehension does not work: > > TypeError: enumerate() takes exactly 1 argument (2 given) > > > On Aug 29, 2009, at 12:20 AM, vince spicer wrote: > > >> >>

Re: [Tutor] Boolean operations

2009-09-02 Thread vince spicer
On Wed, Sep 2, 2009 at 4:30 AM, Anthony Casey wrote: > Hello, tutors. > > I'm someone who used to programme as a hobby and who is trying to get back > into it via Python. I'm reading Programming in Python 3 by Summerfield > (excellent book). > > I read something unusual about Boolean operations i

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

2009-09-02 Thread vince spicer
On Wed, Sep 2, 2009 at 7:55 AM, Kristina Ambert wrote: > Hi, > > I just wanted to ask if everyone else gets this message as a first reply > everytime you send out a message to tutor. > It feels like I'm getting spam or something. > Geneviève DIAGORN to me > show details 3:59 PM (17 hours ago) > >

Re: [Tutor] Getting list of attributes from list of objects

2009-09-10 Thread vince spicer
On Thu, Sep 10, 2009 at 8:51 AM, Oleg Oltar wrote: > Hi! > > I have the following list > > l= [ a, b, c] > > Where a,b,c are objects created from one class, e.g. each has title > attribute. > What I want to have is a list of titles, e.g. [a.title, b.title, c.title] > > Is there a quick way to do

Re: [Tutor] Image manipluation (On-the-fly thumbnail creation)

2009-09-15 Thread vince spicer
On Tue, Sep 15, 2009 at 10:03 AM, dan06 wrote: > > I've recently delved into python, about a week or so ago; I'm trying to > figure out how to create on-the-fly thumbnails. Are there python standard > library modules I could/should use or should I use external libraries like: > GD, Gimp, or Image

Re: [Tutor] Help required

2009-09-25 Thread vince spicer
On Fri, Sep 25, 2009 at 1:56 PM, waqas ahmad wrote: > > > Hi, > > I dont know it is the right place to post this question. I need help to > change one search code line . can you help me please. > > here is my search method code: > > search=re.compile("^#acl InternationalGroup.*\n", re.M).search(

Re: [Tutor] help with alternate execution

2009-09-29 Thread vince spicer
On Tue, Sep 29, 2009 at 10:59 AM, wrote: > I'm trying to make a very simple example to show alternate execution... if > a > number is divisible by 3 it will say so and if it isnt, it will say so. > Heres my > program > > n= raw_input("enter a number= ") > def divisible(n): >if n%3 == 0: >

Re: [Tutor] how to run php scripts in pylons framework?

2009-10-02 Thread vince spicer
On Fri, Oct 2, 2009 at 1:24 AM, ggi ggi wrote: > > Dear All, > > I have some php scripts which I don't want to rewrite in python. How can I > run php Scripts in python? > > Thanks in advance > Googi G > > ___ > Tutor maillist - Tutor@python.o

Re: [Tutor] Package for verify validity of any kind of IP

2009-10-08 Thread vince spicer
On Thu, Oct 8, 2009 at 2:38 AM, Ansuman Dash wrote: > Hi, > > Can anybody suggest me a package to verify validity of any kind of IP, i.e. > IPv4 or IPv6. > > Thanks, > AD > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscript

Re: [Tutor] Help with pexpect

2009-10-16 Thread vince spicer
On Fri, Oct 16, 2009 at 1:45 PM, Nathan Farrar wrote: > I'm trying to automate the collection of data to remote devices over > ssh via pexpect. I had originally attempted (with limited success) to > use paramiko, however due to cisco's ssh implimentation I cannot send > mulitple commands over the

Re: [Tutor] Testing for empty list

2009-10-18 Thread vince spicer
On Sun, Oct 18, 2009 at 7:29 PM, Wayne wrote: > Hi, I think I recall seeing this here, but I wanted to make sure I'm > correct. > Is the best way to test for an empty list just test for the truth value? > I.e. > > mylist = [1,2,3] > > while mylist: >print mylist.pop() > > Thanks, > Wayne > >

Re: [Tutor] "if clause" in list comprehensions.

2009-10-19 Thread vince spicer
On Mon, Oct 19, 2009 at 1:58 PM, Emile van Sebille wrote: > On 10/19/2009 12:20 PM Alan Gauld said... > > >> "Sander Sweers" wrote >> >> mylist = ['John', 'Canada', 25, 32, 'right'] a = [item.upper() for item in mylist if type(item) == type('good')] >>> >>> Usually it is recommended t

Re: [Tutor] "if clause" in list comprehensions.

2009-10-19 Thread vince spicer
On Mon, Oct 19, 2009 at 2:14 PM, vince spicer wrote: > > > On Mon, Oct 19, 2009 at 1:58 PM, Emile van Sebille wrote: > >> On 10/19/2009 12:20 PM Alan Gauld said... >> >> >>> "Sander Sweers" wrote >>> >>> mylist = ['John

Re: [Tutor] Pexpect maxread & searchwindowsize, timeout

2009-10-20 Thread vince spicer
On Tue, Oct 20, 2009 at 11:11 AM, Nathan Farrar wrote: > I haven't been able to find any real examples of pexpect usage, nor > documentation. Just little bits here and there, so I'm kind of > struggling through. > > I've got the follow bit of code I'm working with: > > def main(): >try: >

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread vince spicer
On Wed, Oct 21, 2009 at 12:21 PM, Jason Willis wrote: > hi everyone, > > sorry for the rather boring question but i'm having serious issues getting > my programs to run from the command line without having to type "python" > in-front of them. I've tried a lot of different variations on the > #!/us

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread vince spicer
On Wed, Oct 21, 2009 at 12:31 PM, vince spicer wrote: > > > On Wed, Oct 21, 2009 at 12:21 PM, Jason Willis > wrote: > >> hi everyone, >> >> sorry for the rather boring question but i'm having serious issues getting >> my programs to run from the

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread vince spicer
On Wed, Oct 21, 2009 at 12:33 PM, vince spicer wrote: > > > On Wed, Oct 21, 2009 at 12:31 PM, vince spicer wrote: > >> >> >> On Wed, Oct 21, 2009 at 12:21 PM, Jason Willis >> wrote: >> >>> hi everyone, >>> >>> sorry for th

Re: [Tutor] i can't for the life of me get "#! /usr/bin/env python" or "#!/usr/bin/python" to work

2009-10-21 Thread vince spicer
7;m sorry , what am I doing wrong here? > > > On Wed, Oct 21, 2009 at 2:31 PM, vince spicer wrote: > >> >> >> On Wed, Oct 21, 2009 at 12:21 PM, Jason Willis >> wrote: >> >>> hi everyone, >>> >>> sorry for the rather boring question b

Re: [Tutor] replacing a long list of if,elif

2009-10-23 Thread vince spicer
On Fri, Oct 23, 2009 at 9:05 AM, John wrote: > I'm using python 2.5 > > I have a long list of if, elif, else. I always thought it was very NOT > pythonic. It's easy to read but not pretty. > > for fldType in fieldList: > if "int" in fldType: > fld = "I" > elif "char" in fldType : >

Re: [Tutor] Retrieving information from a plain text file (WinXP/py2.6.2/Beginner)

2009-11-02 Thread vince spicer
On Sun, Nov 1, 2009 at 5:37 PM, Katt wrote: > Hello all, > > Thank you all for your help. I appreciate it alot. > > I have been trying to work with file IO alot recently and would like to > improve my little program so that I no longer use a hard coded list, but a > text file that I can edit eas

Re: [Tutor] Unexpected Result in Test Sequence

2009-11-16 Thread vince spicer
On Mon, Nov 16, 2009 at 1:18 PM, wrote: > Hello Tutor list. > I'm running a test to find what the experimental average of a d20 is, and > came across a strange bug in my code. > import random > list1 = [] > def p(): > d = 0 > for number in range(1,1000): > t = random.randrange(1,19) >

Re: [Tutor] Odd result from function call

2011-01-07 Thread Vince Spicer
2) What is actually going on such that only the first digit is being > evaluated? That is, the interpreter knows that x is 10 and y is 5-- and > yet, for some reason the 5 is being tested against the 1 and since 5 is > bigger than 1, it concludes that 5 is

Re: [Tutor] Help listing directory timestamps and deleting directories

2011-01-24 Thread Vince Spicer
_dir = "/path/to/whatever" for r,d,f in os.walk(check_dir): for dir in d: loc = os.path.join(r,dir) last_modified = datetime.fromtimestamp(os.path.getmtime(loc)) if last_modifed < remove_after: print "delete old directory", loc else: print "keep recently modified", loc Hope this helps, Vince Spicer Developer ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Vince Spicer
arim > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vince Spicer Developer ___ T

Re: [Tutor] Python Job Scheduling package

2011-10-13 Thread Vince Spicer
> Tutor maillist  -  Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > -- Vince Spicer ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] Datetime Integers

2012-05-21 Thread Vince Spicer
___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Vince Spicer ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How install Pyramid on a Windows 7 computer?

2012-05-31 Thread Vince Spicer
Step 1) install Ubuntu OK sorry couldn't resist. This should help. http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/install.html#installing-pyramid-on-a-windows-system Vince On Thu, May 31, 2012 at 10:20 AM, Tamar Osher wrote: > Months ago, I learned Python version 3. I have re