Re: help: pandas and 2d table

2024-04-13 Thread Tim Williams via Python-list
On Sat, Apr 13, 2024 at 1:10 PM Mats Wichmann via Python-list < python-list@python.org> wrote: > On 4/13/24 07:00, jak via Python-list wrote: > > doesn't Pandas have a "where" method that can do this kind of thing? Or > doesn't it match what you are looking for? Pretty sure numpy does, but > that

Re: Is there a Python module to parse a date like the 'date' command in Linux?

2023-05-22 Thread Tim Williams
On Mon, May 22, 2023 at 12:41 PM Mats Wichmann wrote: > On 5/20/23 13:53, Chris Green wrote: > > I'm converting a bash script to python as it has become rather clumsy > > in bash. > > > > However I have hit a problem with converting dates, the bash script > > has:- > > > > dat=$(date --date

Re: How to store the result of df.count() as a new dataframe in Pandas?

2021-10-27 Thread Tim Williams
On Tue, Oct 26, 2021 at 6:36 PM Shaozhong SHI wrote: > Hello, > > The result of df.count() appears to be a series object. How to store the > result of df.count() as a new dataframe in Pandas? > > That is data anyhow. > > Regards, > > David > -- > https://mail.python.org/mailman/listinfo/python-l

Re: ValueError: arrays must all be same length

2020-10-05 Thread Tim Williams
data is another table. > > Regards, > > Shao > > > I'm fairly new to pandas myself. Can't help there. You may want to post this on Stackoverflow, or look for a similar issue on github. https://stackoverflow.com/questions/tagged/pandas+json https://github.com/pandas-de

Re: ValueError: arrays must all be same length

2020-10-04 Thread Tim Williams
On Sun, Oct 4, 2020 at 8:39 AM Tim Williams wrote: > > > On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI > wrote: > >> Hello, >> >> I got a json response from an API and tried to use pandas to put data into >> a dataframe. >> >> However, I ke

Re: ValueError: arrays must all be same length

2020-10-04 Thread Tim Williams
On Fri, Oct 2, 2020 at 11:00 AM Shaozhong SHI wrote: > Hello, > > I got a json response from an API and tried to use pandas to put data into > a dataframe. > > However, I kept getting this ValueError: arrays must all be same length. > > Can anyone help? > > The following is the json text. Regard

Re: Python Pandas split Date in day month year and hour

2020-08-19 Thread Tim Williams
etter place to ask a pandas question is StackOverflow. Here's a link that may answer your question. Convert timestamp to day, month, year and hour <https://stackoverflow.com/questions/57515291/convert-timestamp-to-day-month-year-and-hour> Tim Williams -- https://mail.python.org/mailman/listinfo/python-list

Re: conda/anaconda and pip3 (pip)

2018-12-09 Thread Tim Williams
On Saturday, December 8, 2018 at 10:13:14 PM UTC-5, Monte Milanuk wrote: > Did you find any solution(s)? I usually just lurk and read on this list. I don't reply since there's usually more competent people that regularly post helpful answers. (I lurk to learn from them!) If no one's replied yet

Re: Is there a nice way to switch between 2 different packages providing the same APIs?

2018-07-05 Thread Tim Williams
On Thu, Jul 5, 2018 at 9:02 AM Mark Summerfield via Python-list < python-list@python.org> wrote: > For GUI programming I often use Python bindings for Qt. > > There are two competing bindings, PySide and PyQt. > > Ideally I like to have applications that can use either. This way, if I > get a prob

Re: Problem with assignment. Python error or mine?

2017-12-22 Thread Tim Williams
On Friday, December 22, 2017 at 8:41:29 AM UTC-5, Tim Williams wrote: > On Thursday, December 21, 2017 at 12:18:11 PM UTC-5, MarkA wrote: > > On Thu, 21 Dec 2017 07:05:33 -0800, rafaeltfreire wrote: > > From docs.python.org: > > > > 8.10. copy — Shallow and deep copy

Re: Problem with assignment. Python error or mine?

2017-12-22 Thread Tim Williams
On Thursday, December 21, 2017 at 12:18:11 PM UTC-5, MarkA wrote: > On Thu, 21 Dec 2017 07:05:33 -0800, rafaeltfreire wrote: > From docs.python.org: > > 8.10. copy — Shallow and deep copy operations > > Source code: Lib/copy.py > > Assignment statements in Python do not copy objects, they create

Re: matplot plot hangs

2017-11-02 Thread Tim Williams
On Wednesday, November 1, 2017 at 6:30:27 PM UTC-4, Andrew Z wrote: > nope. it doesnt: > > I added print-s after each line and that produced: > [az@hp src]$ cat ./main1.py > import matplotlib.pyplot as plt > print("imported") > plt.plot([1,2,4,1]) > print("plot is done") > plt.show() > print("show

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-30 Thread Tim Williams
On Friday, May 26, 2017 at 12:26:13 PM UTC-4, Peter Otten wrote: > Tim Williams wrote: > > > I've spent too much time trying to track this down. I'll just hard-code my > > filename in my INI file. Maybe I'll get back to it, but I need to move on. > > The o

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Friday, May 26, 2017 at 8:37:38 AM UTC-4, Tim Williams wrote: > On Friday, May 26, 2017 at 8:32:19 AM UTC-4, Tim Williams wrote: > > On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote: > > > On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otte

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Friday, May 26, 2017 at 8:32:19 AM UTC-4, Tim Williams wrote: > On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote: > > On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote: > (snip) > > > ... > > > > > > How do you get >

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-26 Thread Tim Williams
On Thursday, May 25, 2017 at 9:43:40 PM UTC-4, Tim Williams wrote: > On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote: (snip) > > ... > > > > How do you get > > > > > LogFile = '%(CaptureDrive)s%(RootDir)s/test.log' > > &g

Re: using configobj string interpolation and logging.config.dictConfig

2017-05-25 Thread Tim Williams
On Thursday, May 25, 2017 at 5:16:13 PM UTC-4, Peter Otten wrote: > Tim Williams wrote: > > > On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote: > >> Tim Williams wrote: > >> > >> > Just as a followup, if I use 'unrepr=True'

using configobj string interpolation and logging.config.dictConfig (was Re: dictConfig: logging.StreamHandler object is not iterable.)

2017-05-25 Thread Tim Williams
On Wednesday, May 24, 2017 at 5:47:37 PM UTC-4, Peter Otten wrote: > Tim Williams wrote: > > > Just as a followup, if I use 'unrepr=True' in my ConfigObj, I don't have > > to convert the strings. > > I'd keep it simple and would use JSON... I look

Re: dictConfig: logging.StreamHandler object is not iterable.

2017-05-24 Thread Tim Williams
On Wednesday, May 24, 2017 at 2:46:54 PM UTC-4, Tim Williams wrote: > (Apologies for using Google Groups to post) > > I'm trying to use dictConfig to configure logging. I keep running into the > error that the logging.StreamHandler object is not iterable. > > I'm usi

Re: dictConfig: logging.StreamHandler object is not iterable.

2017-05-24 Thread Tim Williams
On Wednesday, May 24, 2017 at 2:46:54 PM UTC-4, Tim Williams wrote: > (Apologies for using Google Groups to post) > > I'm trying to use dictConfig to configure logging. I keep running into the > error that the logging.StreamHandler object is not iterable. > > I'm usi

dictConfig: logging.StreamHandler object is not iterable.

2017-05-24 Thread Tim Williams
(Apologies for using Google Groups to post) I'm trying to use dictConfig to configure logging. I keep running into the error that the logging.StreamHandler object is not iterable. I'm using Python 3.4.3 on a Windows 7 box. C:\Python34\python.exe 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40

Re: numpy array operation

2013-01-29 Thread Tim Williams
On Tuesday, January 29, 2013 3:41:54 AM UTC-5, C. Ng wrote: > Is there a numpy operation that does the following to the array? > > > > 1 2 ==> 4 3 > > 3 4 2 1 > > > > Thanks in advance. >>> import numpy as np >>> a=np.array([[1,2],[3,4]]) >>> a array([[1, 2], [3, 4]]) >>> np.

Re: Accessing dll

2012-09-06 Thread Tim Williams
On Thursday, September 6, 2012 4:21:56 PM UTC-4, Tim Williams wrote: > On Thursday, September 6, 2012 11:07:07 AM UTC-4, Helpful person wrote: > > > I am a complete novice to Python. I wish to access a dll that has > > > > > > been written to be compatible wit

Re: Accessing dll

2012-09-06 Thread Tim Williams
On Thursday, September 6, 2012 11:07:07 AM UTC-4, Helpful person wrote: > I am a complete novice to Python. I wish to access a dll that has > > been written to be compatible with C and VB6. I have been told that > > after running Python I should enter "from ctypes import *" which > > allows P

Re: calling loaded DLL function expecting POINT * argument

2012-09-04 Thread Tim Williams
On Tuesday, September 4, 2012 8:16:33 AM UTC-4, Tim Williams wrote: > On Sunday, August 26, 2012 9:23:49 PM UTC-4, Tim Roberts wrote: > > > Tim Williams wrote: > > > > > > > > > > > > >Hello all, > > > > > > > &g

Re: calling loaded DLL function expecting POINT * argument

2012-09-04 Thread Tim Williams
On Sunday, August 26, 2012 9:23:49 PM UTC-4, Tim Roberts wrote: > Tim Williams wrote: > > > > >Hello all, > > > > > >I'm trying to use the ctypes module to call functions in a DLL. I've > > >figured out how to modify my path so the li

calling loaded DLL function expecting POINT * argument

2012-08-24 Thread Tim Williams
Hello all, I'm trying to use the ctypes module to call functions in a DLL. I've figured out how to modify my path so the library is found, and I can call LoadLibrary on it, but one of the functions expects an array of POINTS. Here is the prototype from the .h file: TRACKER_API HRESULT Initial

Re: problem loading matlab data with ompc and python

2012-05-24 Thread Tim Williams
On May 23, 5:10 pm, no1 wrote: > Hi, we're investigating transitioning our company from matlab to python. We > found OMPC as a MATLAB m-file-to Python translator, but we're encountering a > problem using the translated code to import MATLAB data structures into > Python. For example, when we sa

Re: Accessing the files by last modified time

2012-03-22 Thread Tim Williams
On Mar 22, 7:33 am, Sangeet wrote: > Hi > > I am new to the python programming language. > > I've been trying to write a script that would access the last modified file > in one of my directories. I'm using Win XP. > > I saw a similar topic, on the forum before, however the reply using > (os.pop

Re: Read time and date from a text file

2010-11-24 Thread Tim Williams
On Nov 24, 7:45 am, huisky wrote: > Hi, > > As a newbie, I posted my question here again. > say i have two dics read from a text file by 'split'. > > >>> cstart > > defaultdict(, {15424: ['Dec', '6', '18:57:40'], 552: > ['Dec', '7', '09:31:00'], 15500: ['Dec', '6', '20:17:02'], 18863: > ['Dec', '7

Re: smtplib problem, Unable to relay for

2007-12-21 Thread Tim Williams
On 21/12/2007, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > Hi, > > i get an "Unable to relay for" when trying to send an email from within > my network to an email address not on my domain. > I don't understand why it says "relaying" as i'm sending from an > internal domain user to an external u

Re: Pulling data from a .asps site

2007-11-27 Thread Tim Williams
On 27/11/2007, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > There's a government website which shows public data for banks. We'd > like to pull the data down programmatically but the data is "hidden" > behind .aspx... > > Is there anyway in Python to hook in directly to a browser (firefox or > IE

Re: local variable referenced before assignment

2007-10-25 Thread Tim Williams
On 25/10/2007, A.T.Hofkamp <[EMAIL PROTECTED]> wrote: > On 2007-10-25, Pete Bartonly <[EMAIL PROTECTED]> wrote: > > > Also, brackets around conditions (in the if) are not needed, and comparing > against None is usually done with 'is' or 'is not' instead of '==' or '!='. > The result is then > > if

Re: test if email

2007-10-12 Thread Tim Williams
a message to the addy, if it doesn't bounce, then it's valid. Invalid email doesn't always bounce, ( or the bounces may not always reach you ) :) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: test if email

2007-10-12 Thread Tim Williams
On 12/10/2007, Florian Lindner <[EMAIL PROTECTED]> wrote: > Hello, > is there a function in the Python stdlib to test if a string is a valid > email address? > You mean a valid SMTP email address? In reality, there isn't a way of doing this. But a good rule of thumb is if it hasn't got at least

Re: Finding Peoples' Names in Files

2007-10-11 Thread Tim Williams
On 11/10/2007, brad <[EMAIL PROTECTED]> wrote: > Crazy question, but has anyone attempted this or seen Python code that > does? For example, if a text file contained 'Guido' and or 'Robert' and > or 'Susan', then we should return True, otherwise return False. > -- > http://mail.python.org/mailman/l

Re: Editing particular lines of a text file.

2007-10-09 Thread Tim Williams
# make sure the line ending is intact outfile.write(line) infile.close() outfile.close() or maybe infile = open('infile.txt') outfile = open('outfile.txt','w') new_file = [] for line in infile: if 'msgid' in line: # tr

Re: Putting a line from a text file into a variable, then moving to next line

2007-10-07 Thread Tim Williams
On 07/10/2007, Tim Chase <[EMAIL PROTECTED]> wrote: > > I'm not really sure how readline() works. Is there a way to iterate > > through a file with multiple lines and then putting each line in a > > variable in a loop? > > You can use readlines() to get the whole line (including the > newline): > >

Re: List search

2007-09-28 Thread Tim Williams
x11')] Also, before iterating the whole list check that 'x11' exists if 'x11' in mylist: do stuff and list comprehesions print [x for x in mylist if x == 'x11'] HTH :) Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: recipient validation with smtplib

2007-09-28 Thread Tim Williams
On 28/09/2007, Robin Becker <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > On 28/09/2007, Robin Becker <[EMAIL PROTECTED]> wrote: > >> Is there a way to use smtplib to get recipient validation. I can use > >> smtplib > >> quite happily t

Re: recipient validation with smtplib

2007-09-28 Thread Tim Williams
On 28/09/2007, Robin Becker <[EMAIL PROTECTED]> wrote: > Is there a way to use smtplib to get recipient validation. I can use smtplib > quite happily to send emails using the locahost's sendmail, but sendmail is > just > fire and forget, so some bad addresses eg [EMAIL PROTECTED] don't cause any

Re: I could use some help making this Python code run faster using only Python code.

2007-09-20 Thread Tim Williams
On 21/09/2007, Tim Williams <[EMAIL PROTECTED]> wrote: > On 20/09/2007, Python Maniac <[EMAIL PROTECTED]> wrote: > > I am new to Python however I would like some feedback from those who > > know more about Python than I do at this time. > > > > def scrambleLi

Re: I could use some help making this Python code run faster using only Python code.

2007-09-20 Thread Tim Williams
On 20/09/2007, Python Maniac <[EMAIL PROTECTED]> wrote: > I am new to Python however I would like some feedback from those who > know more about Python than I do at this time. > > def scrambleLine(line): >s = '' >for c in line: >s += chr(ord(c) | 0x80) >return s > > def descramb

Re: trim start and trailing space chars from string

2007-09-15 Thread Tim Williams
On 15/09/2007, Konstantinos Pachopoulos <[EMAIL PROTECTED]> wrote: > Hi, > is there something corresponding to the java String.trim() method, ie > trim start and trailing space/tab chars from string? > say convert " asdf " to "asdf"? >>> ' asdf '.strip() 'asdf' >>> ' asdf '.rstrip() ' asdf' >>>

Re: smtp debugging methods

2007-09-14 Thread Tim Williams
On 14/09/2007, Sean Nakasone <[EMAIL PROTECTED]> wrote: > I'm having trouble with sending smtp mail. It's hanging after the > smtplib.SMTP() line. It doesn't works from home but not from work. What's > the best way to debug this? > > # Here's my script > import smtplib > msg = "Subject: Hello\n\n

Re: extract text from log file using re

2007-09-13 Thread Tim Williams
On 13/09/2007, Fabian Braennstroem <[EMAIL PROTECTED]> wrote: > me again... I should describe it better: > the result should be an array with just: > > 498 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 8.3956e-04 > 3.8560e-03 4.8384e-02 11:40:01 499 > 499 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04

Re: why should I learn python

2007-09-07 Thread Tim Williams
On 07/09/07, Tom Brown <[EMAIL PROTECTED]> wrote: > On Thursday 06 September 2007 16:01, windandwaves wrote: > > Hmmm, thank you all for your replies. I will do some research on the > > net (i did some already, but because I am really not much of a > > programmer, it is often too detailed for me).

Re: startswith( prefix[, start[, end]]) Query

2007-09-06 Thread Tim Williams
On 06/09/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > You may want to try with a regexp, but I'm not sure it's worth it (hint: > the timeit module is great for quick small benchmarks). > > Else, you could as well write your own testing function: > > def str_starts_with(astring, *prefixes)

Re: Image.open( "C:\test.jpg") is this wrong ?

2007-08-27 Thread Tim Williams
On 27/08/07, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 8/27/07, Carnell, James E <[EMAIL PROTECTED]> wrote: > > > Image.open("C:\test.jpg") > > Try: > > Image.open(r"C:\test.jpg") > > See http://docs.python.org/ref/strings.html r"C:\test.jpg" also "C:\\test.jpg" or 'C:/test.jpg' -- http:

Re: Using Regular Expresions to change .htm to .php in files

2007-08-24 Thread Tim Williams
On 24/08/07, J. Cliff Dyer <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > >> Hi, > >> > >> I have a bunch of files that have changed from standard htm files to > >

Re: Using Regular Expresions to change .htm to .php in files

2007-08-23 Thread Tim Williams
On 23/08/07, Tim Williams <[EMAIL PROTECTED]> wrote: > On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I have a bunch of files that have changed from standard htm files to > > php files but all the links inside the site are now br

Re: Using Regular Expresions to change .htm to .php in files

2007-08-23 Thread Tim Williams
On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > > I have a bunch of files that have changed from standard htm files to > php files but all the links inside the site are now broken because > they point to the .htm files while they are now .php files. > > Does anyone have an idea ab

Re: reading a line in file

2007-08-20 Thread Tim Williams
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote: > > Shawn, Tim ,Jay > > many thanks, > > It looks like there are many ways this problem can be approached > > either by using regex or a tokens > > Tim I'm not familiar with your solution, but will learn about that method > also Hi Brian, > bu

Re: reading a line in file

2007-08-20 Thread Tim Williams
On 20/08/07, Shawn Milochik <[EMAIL PROTECTED]> wrote: > Hopefully this will help (using your input file) > > #!/usr/bin/env python > import re > buildinfo = "input.txt" > input = open(buildinfo, 'r') > > regex = re.compile(r"^\s*build.number=(\d+)\s*$") > > for line in input: >if re.search(reg

Re: reading a line in file

2007-08-20 Thread Tim Williams
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote: > > > > > From: [EMAIL PROTECTED] on behalf of Tim Williams > Sent: Mon 8/20/2007 2:59 PM > To: Brian McCann > Cc: python-list@python.org > Subject: Re: reading a line in file &g

Re: reading a line in file

2007-08-20 Thread Tim Williams
On 20/08/07, Brian McCann <[EMAIL PROTECTED]> wrote: > > Hi, > > I can read in the whole file build.number which has the following lines > how do I just capture the value of build.number and assign it to a variable > Thanks, > Brian > > contents of file build.number: > #Build Number for ANT. Do not

Re: clarification

2007-08-18 Thread Tim Williams
On 17/08/07, Beema shafreen <[EMAIL PROTECTED]> wrote: > hi everybody, > i have a file with data separated by tab > mydata: > fhl1fkh2 > dfp1chk1 > mal3alp14 > mal3moe1 > mal3spi1 > mal3bub1 > mal3bub3 > mal3mph1 > mal3mad3 > hob1nak1 > hob1wsp1 > hob1

Re: Problems with headers in email.message

2007-08-04 Thread Tim Williams
ng blank line and a "From nobody" > line) are in the message body, followed by the body text. > > How do I assign values to the header? > > I'd appreciate any help anyone can give me with this. Your script (as posted) works fine for me. I did need to change one import line to: from email.Message import Message (note the capitalization), but that was all - originally it stopped the script dead, so it wasn't the cause of your problem. -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: beginner in python

2007-08-02 Thread Tim Williams
On 02/08/07, Beema shafreen <[EMAIL PROTECTED]> wrote: > Hi everybody , > I am a beginner in python, > I have to fetch the redundant entries from a file, > > code: > > import re > L = [] > fh = open('ARCHITECTURE_MAIN.txt', > 'r') > for line in fh.readlines(): > data =line.st

Re: From D

2007-07-26 Thread Tim Williams
t; y = z.split() > >>> x = ''.join(y) > >>> w = int(x) > >>> w > 123456 but it doesn't if you use replace !! >>> z = '123 456' >>> int( z.replace( ' ' ,'' ) ) > 123456 > Propose: > 123 456 789 => 123456789 > 123.456 789 => 123.456789 +1 for me too -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: Gmail Error using smtplib

2007-07-20 Thread Tim Williams
On 20/07/07, DJ Fadereu <[EMAIL PROTECTED]> wrote: > Hello, can anyone help me with this? What am I doing wrong here? > > (I've changed private info to /xx) > I'm getting an authentication error while using a standard script > Gmail: > --SCRIPT--

Re: Copy List

2007-07-18 Thread Tim Williams
On 18/07/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]> wrote: > > What's the best way to create a copy of a list? I've seen several method and > I'm not sure what to use. This will be in a class and one method creates a > list which I then want to move to the self scope, like so: > listB =

Re: avoid script running twice

2007-06-18 Thread Tim Williams
On 18/06/07, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Tim Williams <[EMAIL PROTECTED]> wrote: > > You can also do this by holding a file open in write mode until the > > script has finished. > > > >try: > > open('lock.txt&

Re: avoid script running twice

2007-06-18 Thread Tim Williams
On 18/06/07, Robin Becker <[EMAIL PROTECTED]> wrote: > Wildemar Wildenburger wrote: > > Robin Becker wrote: > . > > > > Well I can think of a dumb way: create a temporary file during the > > transaction and have your script check for that before running its main > > body. > > > > > > I thin

Re: avoid script running twice

2007-06-18 Thread Tim Williams
> I think thats the most hassle free way of doing it. If the script finishes abnormally, the file will still exist and future execution of the script will fail. :) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: avoid script running twice

2007-06-18 Thread Tim Williams
the file is already open the script won't run, if the script finshes/crashes or the machine reboots the open file will close. In both cases if the script finishes normally or crashes, or the machine is restarted. The lock (ie socket or open file) is released. HTH :) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: smtp server simulation using Python

2007-06-18 Thread Tim Williams
On 17/06/07, William Gill <[EMAIL PROTECTED]> wrote: > I have a (web) development computer w/o an SMTP server and want to test > form generated e-mail using a dummy SMTP server that delivers the mail > message to a file, or better yet, to a text editor instead of actually > sending it. Is it possi

Re: Printing dots in sequence ('...')

2007-05-22 Thread Tim Williams
ce without a space being inserted in between? > maybe this: (on Win32, don't know about *nix) for x in range(10): print '.\b', -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatic login to website (newbie)

2007-05-15 Thread Tim Williams
On 15 May 2007 06:38:45 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm trying to use PAMIE to login to a website: > > import cPAMIE > > # python.org - just a test, works fine > ie = cPAMIE.PAMIE() > website = "http://www.python.org"; > ie.navigate(website) > ie.textBoxSet('q', 'pamie') >

Re: find out all threads?

2007-05-12 Thread Tim Williams
On 11/05/07, Sven Rech <[EMAIL PROTECTED]> wrote: > Hi, > > I have a written a C program which makes use of python embedding. > I want to find out all threads that a loaded module has started. > But I can't find anything about this in the docs. Is it possible? > Without details of your module, its

Re: How to check if a string is empty in python?

2007-05-04 Thread Tim Williams
On 4 May 2007 03:02:37 -0700, Jaswant <[EMAIL PROTECTED]> wrote: > This is a simple way to do it i think > > > s=hello > > >>> if(len(s)==0): > print "Empty" > else: > print s > > hello Not as simple as " If not s: " and nowhere near as simple as " print s or 'Emp

Re: Can't Get Email Interface Working

2007-04-07 Thread Tim Williams
On 07/04/07, Eric Price <[EMAIL PROTECTED]> wrote: > Good grief! And they call a 722-line program "simple"?! LOL! > I did what I need to do with a __one_line_shell_script__ LOL! > Naw, if I have to go through all that, I'll skip on python this time around, > thank you very much! > Eric Yup, its no

Re: way to extract only the message from pop3

2007-04-05 Thread Tim Williams
On 06/04/07, Tim Williams <[EMAIL PROTECTED]> wrote: > Content: ['text/plain', 'text/html', 'message/delivery-status', > 'text/plain', 'text/plain', 'text/plain', 'unknown', 'message/rfc822'

Re: way to extract only the message from pop3

2007-04-05 Thread Tim Williams
ent_type() in required: text_parts.append(part) print ('\r\n' + '='*76 +'\r\n').join(text_parts) # print all the text parts seperated by a line of '=' # end Whether you use the email module or not, you need to join the retrieved message i

Re: way to extract only the message from pop3

2007-04-05 Thread Tim Williams
On 3 Apr 2007 12:36:10 -0700, flit <[EMAIL PROTECTED]> wrote: > Hello All, > > Using poplib in python I can extract only the headers using the .top, > there is a way to extract only the message text without the headers? for i in range( M.stat()[0] ): # M.stat returns msg-count and mbox size ms

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread Tim Williams
On 4 Apr 2007 08:58:49 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > For any list x, x.index(item) returns the index of the FIRST > occurrence of the item in x. Is there a simple way to identify the > LAST occurrence of an item in a list? My solution feels complex - > reverse the list, look

Re: Is any way to split zip archive to sections?

2007-03-31 Thread Tim Williams
On 30/03/07, Durumdara <[EMAIL PROTECTED]> wrote: > Hi! > > I want to create some backup archives with python (I want to write a backup > application in Python). > Some package managers (7z, arj, winzip) can create splitted archives (1 > mega, 650, 700 mega, etc). > > Because I want to ftp these re

Re: File deletion after 72 hours of creation

2007-03-30 Thread Tim Williams
On 29 Mar 2007 13:40:58 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Mar 29, 12:02 pm, [EMAIL PROTECTED] wrote: > > Alex> I'm looking for a simple method to delete a folder after 72 > > Alex> "Business hours" (saturday/sunday doesnt count) since its > > Alex> creation. Note

Re: Sending emails to 3 addresses....

2007-03-30 Thread Tim Williams
On 30/03/07, Tim Williams <[EMAIL PROTECTED]> wrote: Emile, (slight change to my original reply) You are passing the TO addresses as 3 addresses in a single string. [TO] results in a list containing a single string - not a list containing 3 individual addresses. You need to either pa

Re: Sending emails to 3 addresses....

2007-03-30 Thread Tim Williams
On 30/03/07, Boudreau, Emile <[EMAIL PROTECTED]> wrote: > > sendMail('this is the subject line', 'the results: 71 fails, 229 pass, 300 > total.', '[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]') > > def sendMail(subject, body, TO, FROM="[EMAIL PROTECTED]"): > print TO > HOST = "ex

Re: Sorting directory contents

2007-02-20 Thread Tim Williams
On 20/02/07, Wolfgang Draxinger <[EMAIL PROTECTED]> wrote: > H folks, > > I got, hmm not really a problem, more a question of elegance: > > In a current project I have to read in some files in a given > directory in chronological order, so that I can concatenate the > contents in those files into a

Re: While loop with "or"? Please help!

2007-01-25 Thread Tim Williams
; But note that 'in' performs a substring search and therefore "yn" and "" > > would be accepted as valid answers, too. > > Mmm, right. Thanks for the correction. > > => > while not usrinp.lower() in ['y', 'n']: or better still while usrinp.lower() not in ['y', 'n']: :):) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: smtplib starttls gmail example - comments?

2007-01-24 Thread Tim Williams
On 24/01/07, BJ Swope <[EMAIL PROTECTED]> wrote: > > > > On 1/24/07, Tim Williams <[EMAIL PROTECTED]> wrote: > > > > On 24/01/07, py <[EMAIL PROTECTED]> wrote: > > > I would love for anybody to comment on this code with regard to > redun

Re: smtplib starttls gmail example - comments?

2007-01-24 Thread Tim Williams
On 24/01/07, py <[EMAIL PROTECTED]> wrote: > I would love for anybody to comment on this code with regard to > redundancy/efficiency/wordiness or whatever else. > for instance, do i understand correctly that i cant have a try: else: without > an intervening except:? > -dave > > stdout.wri

Re: generate tuples from sequence

2007-01-17 Thread Tim Williams
On 17 Jan 2007 04:50:33 -0800, Will McGugan <[EMAIL PROTECTED]> wrote: > > Will McGugan wrote: > > > Hi, > > > > I'd like a generator that takes a sequence and yields tuples containing > > n items of the sqeuence, but ignoring the 'odd' items. For example > > Forgot to add, for my purposes I will a

Re: smtplib question

2007-01-16 Thread Tim Williams
On 16/01/07, gandalf gold <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > I was trying out smtplib and found out that I can email to anyone in my > domain but not to an email address not in the domain. From browsing on the > web, it seems that this has to do with the configuration of the mail serve

Re: Python web app. (advice sought)

2007-01-16 Thread Tim Williams
On 16/01/07, Ralf Schönian <[EMAIL PROTECTED]> wrote: > > I would also like to vote for Karrigell. > > BTW: Does anyone knows how to avoid stopping/starting of the webserver > after changing external libraries? I have some own modules under > /opt/local/python/lib and import them by extending the

Re: Python web app. (advice sought)

2007-01-15 Thread Tim Williams
On 15 Jan 2007 00:52:33 -0800, Torabisu <[EMAIL PROTECTED]> wrote: > > Duncan Smith wrote: > > Hello, > > I find myself in the, for me, unusual (and at the moment unique) > > position of having to write a web application. I have quite a lot of > > existing Python code that will form part of t

Re: WMI Python, writing remotely and retrieving env variables values

2007-01-13 Thread Tim Williams
On 13 Jan 2007 02:01:11 -0800, Tim Golden <[EMAIL PROTECTED]> wrote: > Thierry Lam wrote: > > I'm using the WMI library for python and I was able to connect to > > another computer on the network with the following line: > > > > c = wmi.WMI(computer="the-network-computer", user="hello", > > passwor

Re: parsing a file name

2007-01-12 Thread Tim Williams
On 12 Jan 2007 09:16:51 -0800, CSUIDL PROGRAMMEr <[EMAIL PROTECTED]> wrote: > I have a filename > cairo-2.3.4.src.rpm > Is there any way i can only get 2.3.4 from this file name Is this a one off, or do you have to process multiple files with similar names? -- Tim Wi

Re: recursive function

2007-01-08 Thread Tim Williams
On 8 Jan 2007 16:03:53 +0100, Neil Cerutti <[EMAIL PROTECTED]> wrote: > > len(dict.keys()). > Or len(dict) :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing files in a zip to files on drive

2006-12-28 Thread Tim Williams
om/wndsync/help/sources/abit.htm -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: win32 service

2006-12-16 Thread Tim Williams
On 16/12/06, g.franzkowiak <[EMAIL PROTECTED]> wrote: > Hi everybody, > > have a little problem with a service on Win32. > > I use a TCP server as service, but can't access from an other machine. > Only local access is possible. > > The service starts like this: > > -> myService.py --username user

Re: parsing a dictionary from a string

2006-12-15 Thread Tim Williams
On 15/12/06, Benjamin Georgi <[EMAIL PROTECTED]> wrote: > Hello list, > > I could use some help extracting the keys/values of a list of > dictionaries from a string that is just the str() representation of the > list (the problem is related to some flat file format I'm using for file > IO). > > Exa

Re: "10, 20, 30" to [10, 20, 30]

2006-11-23 Thread Tim Williams
On 23/11/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > >>>> > > and the use of a list comprehension is pretty silly to, given that you want > to apply the same *function* to all items, and don't really need to look > it up

Re: socket.error connection refused

2006-11-23 Thread Tim Williams
On 23 Nov 2006 04:09:18 -0800, Vania <[EMAIL PROTECTED]> wrote: > Hi, I'm not sure this is the proper forum but I try nevertheless. > The problem I'am facing is that the socket library always fail to > connect to an URL. The net effect is that I can not use setuptools. > I'm using Python2.4 on a wi

Re: "10, 20, 30" to [10, 20, 30]

2006-11-23 Thread Tim Williams
On 23/11/06, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 23 Nov 2006 03:13:10 -0800, Daniel Austria wrote: > > > Sorry, > > > > how can i convert a string like "10, 20, 30" to a list [10, 20, 30] > > > > what i can do is: > > > > s = "10, 20, 30" > > tmp = '[' + s + ']' > > l = eval(tmp) >

Re: "10, 20, 30" to [10, 20, 30]

2006-11-23 Thread Tim Williams
On 23 Nov 2006 03:13:10 -0800, Daniel Austria <[EMAIL PROTECTED]> wrote: > Sorry, > > how can i convert a string like "10, 20, 30" to a list [10, 20, 30] > > what i can do is: > > s = "10, 20, 30" > tmp = '[' + s + ']' > l = eval(tmp) > > but in my opinion this is not a nice solution > Not nice, e

Re: string to list of numbers conversion

2006-11-10 Thread Tim Williams
On 5 Nov 2006 04:34:32 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi, > I have a string '((1,2), (3,4))' and I want to convert this into a > python tuple of numbers. But I do not want to use eval() because I do > not want to execute any code in that string and limit it to list of > num

Re: Getting externally-facing IP address?

2006-11-10 Thread Tim Williams
On 10/11/06, Tim Williams <[EMAIL PROTECTED]> wrote: > > > On 10/11/06, Michael B. Trausch <[EMAIL PROTECTED]> wrote: > > > > > > > > Every programming example that I have seen thus far shows simple server > code and how to bind to a socket--however

  1   2   3   >