Re: How to get user home directory on Windows

2008-01-13 Thread Tim Golden
thebjorn wrote: > On Jan 12, 6:50 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: >> Update. >> I found a way for getting the home directory of the user but it >> requires to validate the user by providing username+password: >> >> def get_homedir(username, password): >> token = win32security

Re: paging in python shell

2008-01-13 Thread Tim Roberts
t;more"? The Python shell does that for the "help" command, but maybe you could post a more precise example of what you want. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get user home directory on Windows

2008-01-13 Thread Tim Golden
Martin P. Hellwig wrote: > Giampaolo Rodola' wrote: >> Hi all, >> I'm trying to use the pywin32 extension to find out the user's home >> directory but currently I didn't find a solution yet. >> What I'd need to do is not getting the home directory of the currently >> logged in user but something li

Re: short path evaluation, why is f() called here: dict(a=1).get('a', f())

2008-01-14 Thread Tim Chase
> But how can Python determine when you want the result to be *the > callable* and when you want it to be *the result of calling the > callable*? > > Functions and other callables are first-class objects, and it is quite > reasonable to have something like this: > > map = {'a': Aclass, 'b': B

Re: hide object property from dir() function?

2008-01-15 Thread Tim Golden
jerryji wrote: > Sorry for this newbie question, I was puzzled why the existing > property of an object is not shown in the dir() function output. The under-development version of Python (2.6) allows for a __dir__ magic method by which the class implementer can return whatever he wishes from a dir

Re: common problem - elegant solution sought

2008-01-15 Thread Tim Golden
Helmut Jarausch wrote: > I'm looking for an elegant solution of the following tiny but common problem. > > I have a list of tuples (Unique_ID,Date) both of which are strings. > I want to delete the tuple (element) with a given Unique_ID, but > I don't known the corresponding Date. > > My straigh

Re: Python help for a C++ programmer

2008-01-16 Thread Tim Chase
> I want something like (C++ code): > > struct Response > { >std::string name; >int age; >int iData[ 10 ]; >std::string sData; > }; > > // Prototype > void Process( const std::vector& ); > > int main() > { >std::vector responses; > >while( /* not end of file */ )

Re: Creating unique combinations from lists

2008-01-16 Thread Tim Chase
> a = ['big', 'small', 'medium']; > b = ['old', 'new']; > c = ['blue', 'green']; > > I want to take those and end up with all of the combinations they > create like the following lists > ['big', 'old', 'blue'] > ['small', 'old', 'blue'] > ['medium', 'old', 'blue'] > ['big', 'old', 'green'] > ['sma

Re: Creating unique combinations from lists

2008-01-16 Thread Tim Chase
>> I could do nested for ... in loops, but was looking for a Pythonic way >> to do this. Ideas? > > What makes you think nested loops aren't Pythonic? On their own, nested loops aren't a bad thing. I suspect they become un-Pythonic when they make code look ugly and show a broken model of the

Re: Creating unique combinations from lists

2008-01-16 Thread Tim Chase
>> for a in range(5): > ... >>for z in range(5): > > means the inner loop runs 5**26 times so perhaps it's not only > unpythonic but also uncomputable... only if you're impatient ;) yes, it was a contrived pessimal example. It could be range(2) to generate boolean

Re: Opening/Running files through python

2008-01-17 Thread Tim Golden
Ionis wrote: > Hey guys, hope you can help me here. > > I am running in windows and I am trying to open a file via python. I > want the file (a text file) to open up in the users default text > editor. I'm not wanting to read a file, I just want to open it. Is > there a way? import os os.startfi

Re: Creating unique combinations from lists

2008-01-17 Thread Tim Chase
>> You can use a recursive generator: >> >>def iterall(*iterables): >> if iterables: >>for head in iterables[0]: >> for remainder in iterall(*iterables[1:]): >>yield [head] + remainder >> else: >>yield [] >> >>for thing in iterall( >>['

Re: ANN:proxysocket(socks4,socks5)v0.1

2008-01-17 Thread Tim Roberts
variables do, what the states mean, etc. It's easy to do; you just start the text with # signs. # This function allows you to ... # These variables define the connection state as the connection is # made. They're great. You should try them. -- Tim Roberts, [EMAIL PROTECTED] Pr

Re: Efficient processing of large nuumeric data file

2008-01-18 Thread Tim Chase
> for line in file: The first thing I would try is just doing a for line in file: pass to see how much time is consumed merely by iterating over the file. This should give you a baseline from which you can base your timings > data = line.split() > first = int(data[0]) > >

Re: What is a shortcut to the Default home directory in Windows

2008-01-18 Thread Tim Golden
Christian Heimes wrote: > Mike Driscoll wrote: >> I personally use Tim Golden's excellent win32 API wrapper, the >> winshell script. You can find it here: >> >> http://timgolden.me.uk/python/winshell.html > > Yeah. Tim's winshell is fine but it's

Re: TopSort in Python?

2008-01-20 Thread Tim Peters
pyright (c) 1999-2008 Tim Peters Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,

Re: Transforming ascii file (pseduo database) into proper database

2008-01-21 Thread Tim Chase
> I need to take a series of ascii files and transform the data > contained therein so that it can be inserted into an existing > database. [snip] > I need to transform the data from the files before inserting > into the database. Now, this would all be relatively simple if > not for the followin

Re: I don't understand what is happening in this threading code

2008-01-21 Thread Tim Roberts
Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> id(True) 504958236 >>> a = True >>> id(a) 504958236 >>> id(False) 504958224 >>&g

Re: py2exe and modules question

2008-01-21 Thread Tim Roberts
eter DLL, and any DLLs they might need, and shove them in a single file (.zip, in the py2exe case). The parts get extracted for execution. The distribution will still contain the .pyc files, and there are tools that can decompile a .pyc without much trouble. -- Tim Roberts, [EMAIL PROTECTED]

Re: stdin, stdout, redmon

2008-01-22 Thread Tim Golden
Bernard Desnoues wrote: > Hello, > > I checked under linux and it works : > text.txt : > "first line of the text file > second line of the text file" > > test.py : > "import sys > a = sys.stdin.readlines() > x = ''.join(a) > x = x.upper() > sys.stdout.write(x)" > > >cat text.txt | python test.p

Re: question

2008-01-22 Thread Tim Chase
> def albumInfo(theBand): > def Rush(): > return ['Rush', 'Fly By Night', 'Caress of Steel', '2112', 'A Farewell to Kings', 'Hemispheres'] > > def Enchant(): > return ['A Blueprint of the World', 'Wounded', 'Time Lost'] > > The only problem with the code above though is that

Re: what's wrong with the wmi.Terminate() method?

2008-01-23 Thread Tim Golden
[EMAIL PROTECTED] wrote: [... snip same problem as reported to python-win32 ...] See my reply on python-win32. TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess and & (ampersand)

2008-01-23 Thread Tim Golden
for this? How do I get "&" treated > like a regular character using the subprocess module? A little experimentation suggests that the problem's somehow tied up with the .bat file. ie this works for me (doubly complicated because of the long firefox path: import subproce

Re: subprocess and & (ampersand)

2008-01-23 Thread Tim Golden
Steven Bethard wrote: > I'm having trouble using the subprocess module on Windows when my > command line includes special characters like "&" (ampersand):: > > >>> command = 'lynx.bat', '-dump', 'http://www.example.com/?x=1&y=2' > >>> kwargs = dict(stdin=subprocess.PIPE, > ... std

Re: wxpython

2008-01-23 Thread Tim Golden
joe jacob wrote: > I am trying to open a file containing non displayable characters like > contents an exe file. The is is with the below mentioned code: > > self.text_ctrl_1.SetValue(file_content) > > If the file_content contains non displayable characters I am getting > an error like this: > >

Re: csv to xls using python 2.1.3

2008-01-23 Thread Tim Golden
LizzyLiz wrote: > Hi > > I need to convert a .csv file to .xls file using python 2.1.3 which > means I can't use pyExcelerator! Does anyone know how I can do this? > > Many thanks > LizzyLiz Use win32com.client to start Excel, tell it to .Open the .csv file and then tell it to .SaveAs an Excel

Re: subprocess and & (ampersand)

2008-01-23 Thread Tim Golden
Ross Ridge wrote: > Tim Golden <[EMAIL PROTECTED]> wrote: >> but this doesn't: >> >> >> "c:\Program Files\Mozilla Firefox\firefox.exe" "%*" >> >> >> >> import subprocess >> >> cmd = [ >> r"

Re: Python CGI script and CSS style sheet

2008-01-23 Thread Tim Chase
> I'm working with a Python CGI script that I am trying to use with an > external CSS (Cascading Style Sheet) and it is not reading it from the > web server. The script runs fine minus the CSS formatting. Does > anyone know if this will work within a Python CGI? It seems that line > 18 is not be

Re: Python printing!

2008-01-23 Thread Tim Golden
SMALLp wrote: > Hy. How to use printer in python. I goggled little i I found only some > win32 package which doesn't look processing for cross platform > application. (I'm using USB printer and I tried to f=open("dev/...") usb > port but i couldn't fond where printer is! You perhaps want to lo

Re: Automatically Writing a Dictionary

2008-01-23 Thread Tim Chase
> input = "/usr/local/machine-lang-trans/dictionary.txt" > > input = open(input,'r') > > dict = "{" > for line in input: > ? tup = re.split(','line) > ? dict += '"' + tup[0] +'":"' + tup[1] +'", ' > dict += "}" > input.close() > > > Of course, that will just give me a string. How do I convert >

handling asynchronous callbacks from c++ in a python script

2008-01-23 Thread Tim Spens
I have a c++ program running that has boost python hooks for the c++ api. I'm running a python client that makes calls into the c++ api. The problem is there are c++ asynchronous callbacks that need to pass information to the python client. What I was hoping to do is call a python function from

Re: translating Python to Assembler

2008-01-24 Thread Tim Roberts
he intermediate language created by the Python "compiler". -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: sudoku solver in Python ...

2008-01-24 Thread Tim Roberts
llection of interesting public domain Python scripts for numerical analysis and linear programming problems and puzzles. http://www.ics.uci.edu/~eppstein/ -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython

2008-01-24 Thread Tim Golden
[Tim Golden] >> wxPython is trying to interpret your byte stream as a Unicode >> text stream encoded as cp1252. But it's not, so it gives up >> in a heap. One solution is to pass the repr of file_content. >> Another solution is for you to prefilter the text, replaci

Re: wxpython

2008-01-24 Thread Tim Golden
[... snip stuff from TJG ...] joe jacob wrote: > Thanks for the information. I'll try to manage it some how. If you haven't already, try posting to a wxPython or wxWidgets mailing list; maybe someone's already done this kind of thing? TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Designing website

2008-01-24 Thread Tim Chase
> I am planning to design a website using windows, apache, mysql, > python. You don't mention what sort of website...low-volume or high-volume, basic text or graphic-intensive, simple design or complex web-application logic. Each of these factors into one's choice. > But I came to know that pyth

Re: Beginner Pyserial Question

2008-01-24 Thread Tim Spens
COM = 0 #for COM1 BAUD = 115200 class serial_port(): def __init__(self): self.start_time = None self.end_time = None self.asleep_duration = None self.device = serial.Serial() self.device.timeout = 1 self.device.baudrate = BAUD self.devic

Re: Linux Journal Survey

2008-01-24 Thread Tim Chase
>> want to vote for Python. http://www.linuxjournal.com/node/1006101 > > 18. What is your favorite programming language? > > (15 choices, Python not included) I'm not sure why some folks have their knickers in a knot...I took the survey and there was an "Other" box, so I just wrote in "Python

global/local variables

2008-01-24 Thread Tim Rau
What makes python decide whether a particular variable is global or local? I've got a list and a integer, both defined at top level, no indentation, right next to each other: allThings = [] nextID = 0 and yet, in the middle of a function, python sees one and doesn't see the other: class ship(thi

Re: global/local variables

2008-01-24 Thread Tim Rau
On Jan 24, 7:09 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 24 Jan 2008 15:37:09 -0800, Tim Rau wrote: > > What makes python decide whether a particular variable > > is global or local? > > For starters, if the line of code is not

Re: global/local variables

2008-01-25 Thread Tim Rau
On Jan 25, 5:31 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 24 Jan 2008 23:04:42 -0800, Tim Rau wrote: > > UnboundLocalError: local variable 'nextID' referenced before assignment > > When you assign to a name in Python, the comp

Re: global/local variables

2008-01-25 Thread Tim Rau
On Jan 25, 5:31 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 24 Jan 2008 23:04:42 -0800, Tim Rau wrote: > > UnboundLocalError: local variable 'nextID' referenced before assignment > > When you assign to a name in Python, the comp

Re: Puzzled by behaviour of class with empty constructor

2008-01-25 Thread Tim Rau
On Jan 25, 5:54 pm, [EMAIL PROTECTED] wrote: > On Jan 25, 5:46 pm, Bjoern Schliessmann > > > [EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > print x.ends,y.ends,z.ends > > > # > > > Running the following code outputs: > > [(0, 2)] [(0, 2)] [(0, 2)] > > > > Can anyone

Re: looking for a light weighted library/tool to write simple GUI above the text based application

2008-01-25 Thread Tim Rau
On Jan 25, 10:25 pm, [EMAIL PROTECTED] wrote: > > I agree that SDL is probably the best choice but for the sake of > > completeness, Gtk can (at least in theory - I've never tried it) be > > built against directfb and run without X. > > from the Pygame Introduction: Pygame is a Python extension lib

Doesn't know what it wants

2008-01-25 Thread Tim Rau
Traceback (most recent call last): File "C:\Documents and Settings\Owner\My Documents\NIm's code\sandbox \sandbox.py", line 242, in player = ship() File "C:\Documents and Settings\Owner\My Documents\NIm's code\sandbox \sandbox.py", line 121, in __init__ self.phyInit() File "C:\Docume

Re: Doesn't know what it wants

2008-01-25 Thread Tim Rau
On Jan 26, 1:41 am, John Machin <[EMAIL PROTECTED]> wrote: > On Jan 26, 4:20 pm, Tim Rau <[EMAIL PROTECTED]> wrote: > > > > > Traceback (most recent call last): > > File "C:\Documents and Settings\Owner\My Documents\NIm's code\sandbox > &g

Re: Doesn't know what it wants

2008-01-25 Thread Tim Rau
On Jan 26, 1:32 am, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED] nomine.org> wrote: > -On [20080126 06:26], Tim Rau ([EMAIL PROTECTED]) wrote: > > >Line 147 reads: > >moi = cp.cpMomentForCircle(self.mass, .2, 0, vec2d((0,0))) > > I think it expects som

Re: How can I use the up and down, left and right arrow keys to control a Python Pgm

2008-01-25 Thread Tim Rau
On Jan 25, 10:48 pm, "jitrowia" <[EMAIL PROTECTED]> wrote: > I was wondering what kind of python code I would need to enable me to > use the up and down, left and right arrow keys to control software > programming decisions within a Python Program. > > Any direction and advice would be greatly appr

Re: Windows AVIFile problems

2008-01-25 Thread Tim Golden
c d saunter wrote: > I'm trying to access individual video frames of an AVI file from within > Python 2.4 or 2.5 under Windows XP. I thought that the recently-at-1.0 pyglet did that, only I can't now see it in their docs anywhere. Might be worth asking over there anyway [1] since it certainly com

Re: Minimum Requirements for Python

2008-01-25 Thread Tim Chase
> Can someone tell me the minimum requitements for Python as I can't > find it anwhere on the site. I have 3 PC's which are only 256mb RAM, > wanted to know if this was sufficenent. It runs just fine here on an old P133 laptop running OpenBSD with a mere 32 megs of memory. I wouldn't do numerical

Re: Automatically Writing a Dictionary

2008-01-25 Thread Tim Chase
>> d = dict(line.split(',').rstrip('\n')? > > Thanks. That worked except for the rstrip. So I did this: Sorry...I got the order wrong on them (that's what I get for editing after copy&pasting). They should be swapped: d = dict(line.rstrip('\n').split(',')) to strip off the newline before you

Re: Doesn't know what it wants

2008-01-26 Thread Tim Rau
Jeroen Ruigrok van der Werven <[EMAIL PROTECTED] > > > nomine.org> wrote: > > >> -On [20080126 06:26], Tim Rau ([EMAIL PROTECTED]) wrote: > > > >> >Line 147 reads: > > >> >moi = cp.cpMomentForCircle(self.mass, .2, 0, vec2d((0,0))) > > &g

Re: py3k feature proposal: field auto-assignment in constructors

2008-01-27 Thread Tim Chase
> This is neat. :) Could that maybe be extended to only assign selected > args to the instance and let others pass unchanged. So that, for instance: > > @autoassign("foo", "bar") > def __init__(self, foo, bar, baz): > super(baz) I've seen some folks import inspect/functools, but from my tes

Re: starting programs from python script on windows

2008-01-28 Thread Tim Golden
Benedict Verheyen wrote: > i want to automate starting programs on my windows machine and i want > to do it with windows. > This is a sample script: > > from subprocess import Popen, PIPE > import time > > print " Starting app 1" > time.sleep(1) > try: > p1 = Popen(["C:\Program Files\Microso

Re: Encryption Recommendation

2008-01-28 Thread Tim Chase
> Usually, one doesn't store clear-text passwords. Instead, use a > hash-algorithm like md5 or crypt (the former is in the standard lib, don't > know of the other out of my head) and hash the password, and store that > hash. Python offers md5, and SHA modules built-in. (yay, python!) http://d

Re: Get Available Functions

2008-01-28 Thread Tim Chase
> I'm working with a python module which isn't part of the core > Python API and it also isn't very documented or supported, is > there any way that I can easily dump/view the available > classes and methods within the package from within python? Most of the time, the dir(), type() and help() func

Re: referer url

2008-01-28 Thread Tim Chase
> I was wondering, if there is a way to retrieve the referer url with > python (web-based). > I tried this: > > import os > print os.getenv('HTTP_REFERER') > > but it's not working, even thought other http variables do function, > this one is always a None. This could be for any number of reason

Re: referer url

2008-01-28 Thread Tim Chase
> 1) CGI so i'm doing it right. that's helpful to know > 2) this is impossible as i'm doing the exact same thing with another > language and it utterly works. Just making sure...same browser/setup/configuration, different language? > 3) the same as above kinda figured...most servers give you

Re: py3k feature proposal: field auto-assignment in constructors

2008-01-28 Thread Tim Chase
> I've modified my little decorator (see Test1, Test2, Test3 for > usage). I'll post it later on the cookbook if there seems to be no > bugs and noone raises valid point against it:) One other area that was mentioned obliquely: preservation of docstrings (and other function attributes) I could

Executing other python code

2008-01-28 Thread Tim Rau
I'm working on a game, and I'd like players to be able to define thier ships with scripts. Naturally, I don't want to give them the entire program as thier romping ground. I would like to invoke a seperate interpreter for these files, and give it a limited subset of the functions in my game. What i

Re: Zipfile content reading via an iterator?

2008-01-29 Thread Tim Chase
>>> I'm dealing with several large items that have been zipped up to >>> get quite impressive compression. However, uncompressed, they're >>> large enough to thrash my memory to swap and in general do bad >>> performance-related things. I'm trying to figure out how to >>> produce a file-like iter

Re: MySQLdb

2008-01-29 Thread Tim Chase
> i have problem manipulating mySQL data. When i add values in a Table, > i can recieve them instantly but when i check the table from another > script, the new values dont exist. Depending on your transaction settings (both on your mysql connection object in code, and the engine used for the tabl

Re: find nearest time in datetime list

2008-01-30 Thread Tim Golden
washakie wrote: > Hello, > > I have a list of datetime objects: DTlist, I have another single datetime > object: dt, ... I need to find the nearest DTlist[i] to the dt is > there a simple way to do this? There isn't necessarily an exact match... import datetime dates = [datetime.date (20

Re: find nearest time in datetime list

2008-01-30 Thread Tim Chase
> I have a list of datetime objects: DTlist, I have another single datetime > object: dt, ... I need to find the nearest DTlist[i] to the dt is > there a simple way to do this? There isn't necessarily an exact match... import datetime dates = [datetime.datetime(2007,m, 1) for m in range(1,1

Re: find nearest time in datetime list

2008-01-30 Thread Tim Chase
Boris Borcic wrote: > min(DTlist,key=lambda date : abs(dt-date)) In Python2.4: Traceback (most recent call last): File "", line 1, in ? TypeError: min() takes no keyword arguments Looks like min() only started taking keywords (key) from Python2.5 forward. But the min() solution is g

Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-01-30 Thread Tim Chase
> I do not understand why no one has answered the following question: > > Has anybody worked with Gene Expression Programming Well, my father's name is Gene, and he's expressed software wants that I've implemented in Python...so yes, I guess I've done some Gene Expression Programming... ;

Re: Telnet Program

2008-01-30 Thread Tim Roberts
net session, the user is going to press CR when its through with a line. Thus, I would think he needs either \r\r or \n\n. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Telnet Program

2008-01-30 Thread Tim Roberts
hould be getting back a 'OK' or 'ERROR'. But I >am not seeing it. I feel like I am missing something. Not sure what >would be the or is it the telnet application itself. Are you talking to a modem here? Are you sure you don't need +++ to get its attention before sending AT commands? -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-02-01 Thread Tim Chase
> I actually expect hell to have the largest computing powers in > the universe. What do you think how many IBM, Solaris, > don't-ask-me-what machines admins have already sent down > there? Seems like they'd have trouble with cooling problems... (okay, I was just told yesterday that "hell is hot"

Re: Why the HELL has nobody answered my question !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-02-01 Thread Tim Golden
Bjoern Schliessmann wrote: > Stefan Behnel wrote: > >> How do you know people in hell aren't doing any programming in >> Python? > > Common sense. In hell, everything is hacked together using Perl. Although see: http://xkcd.com/224/ TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: How to convert markup text to plain text in python?

2008-02-01 Thread Tim Chase
> I have some marked up text and would like to convert it to plain text, > by simply removing all the tags. Of course I can do it from first > principles but I felt that among all Python's markup tools there must > be something that would do this simply, without having to create an > XML parser etc

Re: How to convert markup text to plain text in python?

2008-02-01 Thread Tim Chase
>> Well, if all you want to do is remove everything from a "<" to a >> ">", you can use >> >> >>> s = "Today is Friday" >> >>> import re >> >>> r = re.compile('<[^>]*>') >> >>> print r.sub('', s) >> Today is Friday >> [Tim's ramblings about pathological cases snipped] > > The real answer

build tool opinions

2008-02-01 Thread Tim Arnold
now I like the fact that SCons and A-A-P are both written in Python; On the other hand I think I could use Jython and Ant too. Any ideas/opinions/advice would be helpful. --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: string split without consumption

2008-02-02 Thread Tim Chase
> this didn't work elegantly as expected: > > >>> ss > 'owi\nweoifj\nfheu\n' > >>> re.split(r'(?m)$',ss) > ['owi\nweoifj\nfheu\n'] Do you have a need to use a regexp? >>> ss.splitlines(True) ['owi\n', 'weoifj\n', 'fheu\n'] -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: What does % mean/does in this context?

2008-02-02 Thread Tim Chase
> for item in cart.values(): > v = _button_cart % {"idx": idx, > "itemname": item.name, > "amount": item.cost, > "quantity": item.quantity,} > cartitems.append(v) > > > What d

Re: string split without consumption

2008-02-02 Thread Tim Chase
>>> this didn't work elegantly as expected: >>> >>> >>> ss >>> 'owi\nweoifj\nfheu\n' >>> >>> re.split(r'(?m)$',ss) >>> ['owi\nweoifj\nfheu\n'] >> Do you have a need to use a regexp? > > I'd like the general case - split without consumption. I'm not sure there's a one-pass regex solution to the

Re: psycopg2

2008-02-02 Thread Tim Roberts
.execute("SELECT * FROM names WHERE name=%s", ('S',) ) Note that the extra comma is required in Python to make a one-element tuple. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows - remote system window text

2008-02-05 Thread Tim Golden
Gabriel Genellina wrote: > En Mon, 04 Feb 2008 17:25:00 -0200, rdahlstrom <[EMAIL PROTECTED]> > escribió: >> On Feb 4, 2:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >>> Well, i guess you will need a process on each machine you need to >>> monitor, and then you do have a client server

Re: Looking for library to estimate likeness of two strings

2008-02-06 Thread Tim Chase
> Are there any Python libraries implementing measurement of similarity > of two strings of Latin characters? It sounds like you're interested in calculating the Levenshtein distance: http://en.wikipedia.org/wiki/Levenshtein_distance which gives you a measure of how different they are. A measu

Re: Why does list have no 'get' method?

2008-02-07 Thread Tim Golden
Denis Bilenko wrote: > Why does list have no 'get' method with exactly the same semantics as > dict's get, > that is "return an element if there is one, but do NOT raise > an exception if there is not.": > > def get(self, item, default = None): > try: > return self[item] >

Re: a trick with lists ?

2008-02-07 Thread Tim Chase
>>> self.tasks[:] = tasks >>> >>> What I do not fully understand is the line "self.tasks[:] = tasks". Why >>> does >>> the guy who coded this did not write it as "self.tasks = tasks"? What is >>> the >>> use of the "[:]" trick ? >> >> It changes the list in-place. If it has been given to ot

Re: beginners help

2008-02-07 Thread Tim Chase
> If i enter a center digit like 5 for example i need to create two > vertical and horzitonal rows that looks like this. If i enter 6 it shows > 6 six starts. How can i do this, because i don't have any clue. > > * > * * > * * > * * > * Well we start by introducing the neophite progr

using scons as a library

2008-02-08 Thread Tim Arnold
I would gain by using SCons is to let my code hand-off tasks to SCons like making and cleaning directories, creating zip files, interacting with CVS, etc. Has anyone tried this before? It seems doable, but if someone has an example that would help to shorten my learning curve. thanks, --Tim Arnol

Re: how to run python script on remote machine

2008-02-08 Thread Tim Golden
Praveena Boppudi (c) wrote: > Can anyone help me in executing python scripts on remote computer? Both > are windows machines. A fair amount depends on just you want to achieve in the wider picture. I'm going to assume that you have Python/pywin32 installed on both machines. You can, for example,

Re: how to run python script on remote machine

2008-02-09 Thread Tim Golden
Tim Golden wrote: > ... You can, for example, use DCOM to instantiate a > remote Python interpreter but the rest you probably be quite hard > word. (Ahem!) Or maybe: You can, for example, use DCOM to instantiate a remote Python interpreter but doing the rest you'll probably find q

Re: Error on Python

2008-02-09 Thread Tim Roberts
) > >The error is coming from this line; >sock.bind ((MCAST_ADDR, MCAST_PORT)) > >Can anyone please help me solve this problem? Where did you get the multicast module? Are you trying to do TCP multicast? What is the address you are trying to use? -- Tim Roberts, [EMAIL PROTECTED]

Re: Better way to do this?

2008-02-11 Thread Tim Chase
> I have a tuple of tuples, in the form--> ((code1, 'string1'),(code2, > 'string2'),(code3, 'string3'),) > > Codes are unique. A dict would probably be the best approach but this > is beyond my control. > > Here is an example: pets = ((0,'cat'),(1,'dog'),(2,'mouse')) > > If I am given a val

Re: how to find current working user

2008-02-11 Thread Tim Chase
> Can anyone tell me how to find current working user in windows? The below should be fairly cross-platform: >>> import getpass >>> whoami = getpass.getuser() >>> print whoami W: tchase L: tim ("W:" is the result on my windows box, "L:&

Re: mmap and shared memory

2008-02-11 Thread Tim Roberts
g around python's mmap module, but I >can't figure how to use it without files. So, let it use a temporary file. What's the harm? An anonymous mmap region is still mapped to the swap file. Might as well give it a name. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boe

Re: dream hardware

2008-02-12 Thread Tim Chase
>>> What is dream hardware for the Python interpreter? > > The only "dream hardware" I know of is the human brain. I have a > slightly used one myself, and it's a pretty mediocre Python interpreter. the human brain may be a pretty mediocre Python interpreter, but darn if I don't miss >>> im

Re: copying files through Python

2008-02-13 Thread Tim Chase
> I am new to python. Infact started yesterday and feeling out of place. > I need to write a program which would transfer files under one folder > structure (there are sub folders) to single folder. Can anyone give me > some idea like which library files or commands would be suitable for > this fil

Re: Complicated string substitution

2008-02-13 Thread Tim Chase
> I have a file with a lot of the following ocurrences: > > denmark.handa.1-10 > denmark.handa.1-12344 > denmark.handa.1-4 > denmark.handa.1-56 Each on its own line? Scattered throughout the text? With other content that needs to be un-changed? With other stuff on the same line? > denmark.han

Re: Getting Wireless Signal Strength / Windows XP

2008-02-14 Thread Tim Golden
[Somehow got stuck in my outbox... ] [EMAIL PROTECTED] wrote: > Hello, > > I'm looking for a way to get wireless signal strength on Windows XP > with Python. I see there's a library for Linux, but I can't find > anything for windows. However, I see that using WMI I can access it in > theory at lea

Re: Solve a Debate

2008-02-15 Thread Tim Chase
> Ok the problem we had been asked a while back, to do a programming > exercise (in college) > That would tell you how many days there are in a month given a > specific month. > > Ok I did my like this (just pseudo): > > If month = 1 or 3 or etc > noDays = 31 > Elseif month = 4 or 6

Re: Help Parsing an HTML File

2008-02-15 Thread Tim Chase
> I need to parse the file in such a way to extract data out of the html > and to come up with a tab separated file that would look like OUTPUT- > FILE below. BeautifulSoup[1]. Your one-stop-shop for all your HTML parsing needs. What you do with the parsed data, is an exercise left to the reade

Re: simple python script to zip files

2008-02-16 Thread Tim Chase
>> I'm just starting to learn some Python basics and are not familiar with >> file handling. >> Looking for a python scrip that zips files. So aaa.xx bbb.yy ccc.xx >> should be zipped to aaa.zip bbb.zip ccc.zip >> >> I haven't been able to type more than 'import gzip'.. Well, you ask for zip fil

Re: simple python script to zip files

2008-02-16 Thread Tim Chase
> Thanks! Works indeed. Strange thing is though, the files created are the > exact size as the original file. So it seems like it is zipping without > compression. The instantiation of the ZipFile object can take an optional parameter to control the compression. The zipfile module only suppor

Re: copying files through Python

2008-02-16 Thread Tim Chase
> OP stated requirements were to move all the files into a single > folder. Copytree will preserve the directory structure from the source > side of the copy operation. well, it would be "copying [not moving] files through Python", but if the desire is to flatten the tree into a single directory,

Re: Understanding While Loop Execution

2008-02-18 Thread Tim Roberts
sub,sub,sub] > >>> full >[[1, 2, 3], [1, 2, 3], [1, 2, 3]] > >>> sub[0] = 123 > >>> full >[[123, 2, 3], [123, 2, 3], [123, 2, 3]] And: >>> full[0][2] = 99 >>> sub [123, 2, 99] >>> full [[123, 2, 99], [123, 2, 99], [123, 2, 99]] -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads vs. continuations

2008-02-19 Thread Tim Daneliuk
me to point out that there is a macro language for Python. It's called 'm4' ... -- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

<    43   44   45   46   47   48   49   50   51   52   >