Pyastro

2007-02-28 Thread l
Where can I find the code... I have checked starship, "the vaults" and googled for a long time. either they point to starshup(wiki) where it doesn't exists, or to dead links. Any help would be much appreciated. TIA -- http://mail.python.org/mailman/listinfo/python-list

PyGeo

2010-08-29 Thread L
has anyone successfully installed PyGeo under python 2.7 (prefer ubuntu 10.04) , the site says http://www.wspiegel.de/pymaxima/index_en.html "Note: The installation of PyGeo work's only under Python 2.4 (The further development of pygeo seems to be stopped)" is this to do with re-org of sit

Re: PyGeo

2010-08-29 Thread L
On 30/08/10 05:00, Thomas Jollans wrote: On Sunday 29 August 2010, it occurred to L to exclaim: has anyone successfully installed PyGeo under python 2.7 (prefer ubuntu 10.04) , the site says http://www.wspiegel.de/pymaxima/index_en.html "Note: The installation of PyGeo work&#

Re: PyGeo

2010-08-30 Thread L
On 30/08/10 18:59, Thomas Jollans wrote: On Monday 30 August 2010, it occurred to L to exclaim: I have tried it and as soon as you try any of the examples in the examples dir it cannot find numpy etc I have manually move the pygeo dirs and contents to /usr/lib/python2.6/dis-packages

Help with 'self' and 'set_usage'

2013-07-09 Thread L O'Shea
Hi all, I'm interning and have been given the job of extending a program that has been written by someone else. I've never used Python before so it's a bit of a struggle but I've got to say I'm loving the language so far. In on of the scripts there is def set_usage(self,s): self.usage_str = s

Re: Help with 'self' and 'set_usage'

2013-07-10 Thread L O'Shea
On Tuesday, 9 July 2013 18:03:41 UTC+1, L O'Shea wrote: > Hi all, > > I'm interning and have been given the job of extending a program that has > been written by someone else. I've never used Python before so it's a bit of > a struggle but I've g

Understanding other people's code

2013-07-12 Thread L O'Shea
Hi all, I've been asked to take over a project from someone else and to extend the functionality of this. The project is written in Python which I haven't had any real experience with (although I do really like it) so I've spent the last week or two settling in, trying to get my head around Pyth

help on python regular expression named group

2013-07-16 Thread Mohan L
27;} need help to correct the below regex (?P(date=(?P[^\s]+))\s+(time=(?P[^\s]+)))" so that It will have : 'datetime': '2012-11-28 21:14:59' instead of 'datetime': 'date=2012-11-28 time=21:14:59' any help would be greatly appreciated Thanks Mohan L -- http://mail.python.org/mailman/listinfo/python-list

Re: help on python regular expression named group

2013-07-16 Thread Mohan L
On Tue, Jul 16, 2013 at 2:12 PM, Joshua Landau wrote: > On 16 July 2013 07:55, Mohan L wrote: > > > > Dear All, > > > > Here is my script : > > > > #!/usr/bin/python > > import re > > > > # A string. > > logs = "dat

Retrieving result from embedded execution

2012-05-08 Thread F L
Hello everyone, We are trying to implement our own interactive interpreter in our applicationusing an embedded Python interpreter. I was wondering what would be the best way to retreive as text the result of executing Python code. The text must be exactly the same as it would be in thestand

RE: Embedded python console and FILE* in python 3.2

2011-08-08 Thread F L
> Is the `code` module (http://docs.python.org/library/code.html) an > insufficiently exact copy of an interpreter for you? The problem isn't really to emulate the behavior of the interpreter as to obtain the result of the execution as a string in c++. The code module doesn't seem to help with

RE: Embedded python console and FILE* in python 3.2

2011-08-08 Thread F L
> If you use the same workflow as you do currently, it won't You're right it shouldn't cause a blocking call. > Come to think of it, you might as well just use StringIO. Yes I could probably replace std{in, out, err} with stringIO objects and retrieve their contents throughthe api. I'll look into

Re: ipython prompt does not appear in windows

2011-05-17 Thread Ori L.
See here for a workaround: https://bugs.launchpad.net/ipython/+bug/290228 First result on Google for the query "ipython emacs windows", BTW. On May 17, 3:00 am, rusi wrote: > If I use ipython under emacs on linux it works (at least basic REPL) > ie I can type an expression and I get a result fol

Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Hi, I have a app loading python35.dll. Use python API PyImport_AddModule to run a py file. And use PyDict_DelItemString to delete the module. There is a global vailable in the py file. The global variable is not destroyed when calling PyDict_DelItemString to delete the module. That cause the memor

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
Thanks for the replay. I run this script as __main__ module, this module is removed from sys.modules, and the ref count becomes 0. 2016-09-20 0:00 GMT+08:00 Chris Angelico : > On Mon, Sep 19, 2016 at 4:47 PM, dl l wrote: > > I have a app loading python35.dll. Use python API PyImport_

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread dl l
equires my customers to update their python scripts. That may make them unhappy :(. Is there a workaround in my code C++ side to call Python C APIs to resolve the memory leak issue? 2016-09-20 13:49 GMT+08:00 Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info>: > On Monday 19 Septembe

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
Thank you all for the help. I found the problem is resolved if call PyGC_Collect() after PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for Python 3.5 which is not needed for Python 3.3? 2016-09-20 16:01 GMT+08:00 Chris Angelico : > On Tue, Sep 20, 2016 at 4:19 PM, d

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread dl l
= 2016-09-21 13:09 GMT+08:00 dieter : > dl l writes: > > I found the problem is resolved if call PyGC_Collect() after > > PyDict_DelItemString(). Is it expected to call PyGC_Collect() here for > > Python 3.5 which is not needed for Python 3.3? > > Usually, Python use

Python C API: How to debug reference leak?

2016-09-26 Thread dl l
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
Thanks for reply. Is there any function in C to get the reference objects of a object? I want to debug where are referencing the object. 2016-09-27 15:01 GMT+08:00 dieter : > dl l writes: > > I want to check the references of an object. Any way to get the > references > >

PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
What is the difference between PyImport_AddModule and PyImport_Import? When need to use PyImport_AddModule? When need to use PyImport_Import? -- https://mail.python.org/mailman/listinfo/python-list

Re: PyImport_AddModule vs PyImport_Import

2016-09-27 Thread dl l
Thanks. That's helpful. I did not notice the note. 2016-09-27 19:24 GMT+08:00 Ned Batchelder : > On Tuesday, September 27, 2016 at 3:54:01 AM UTC-4, dl l wrote: > > What is the difference between PyImport_AddModule and PyImport_Import? > > > > When need to use PyImpo

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
When I debug in C++, I see the reference count of a PyObject is 1. I don't know where is referencing this object. How can I find out where is referencing this object? 2016-09-27 15:47 GMT+08:00 dl l : > Thanks for reply. Is there any function in C to get the reference objects > of

[pyinotify] help required to send only one mail for chunk of events

2016-05-23 Thread Mohan L
Hi All, I am using the bellow script to watch directories. Using 20 seconds to aggregate together a larger chunk of events and enabled coalescing of events. I wanted to send an email notification with content of logfile after 15 mins on any change. The idea is I want to send only one mail for ch

Help to understand the data structure

2019-09-27 Thread Mohan L
: devicename1 10 devicename2 11 devicename3 12 I spend quit some time still not able to figure out how to parse. Can some one through some light on how to phrase it. -- Thanks & Regards Mohan L -- https://mail.python.org/mailman/listinfo/python-list

Re: Help to understand the data structure

2019-09-27 Thread Mohan L
Hi All, Please ignore it, I was able to figure out it. for dev in devlist: print (dev.name, dev.id) -- Thanks & Regards Mohan L On Fri, Sep 27, 2019 at 8:41 PM Mohan L wrote: > Hi All, > > I am using get_devices_list method from this module: > https://github.com/

Re: Character Sequence Generation

2005-09-22 Thread Devan L
Jeff Schwab wrote: > [EMAIL PROTECTED] wrote: > > Jeff Schwab wrote: > > > >>What's the best way to generate a sequence of characters in Python? I'm > >>looking for something like this Perl code: 'a' .. 'z' . > > > > > import string > > > > > print string.ascii_lowercase > > > > abcdefghi

Could this C extension be leaking memory?

2005-09-24 Thread Sam L.
I am trying this out, parts of it are direct from the Python 2.4 manual. //--- icallbk.c #include "Python.h" PyObject *fcallback = NULL; static PyObject* call_func(PyObject* self, PyObject* args) { PyObject *result; PyObject *arglist; int arg = 123; arglist = Py_BuildValue("(i)",

Re: execution order in list/generator expression

2005-10-23 Thread Devan L
[EMAIL PROTECTED] wrote: > Hi, > > I am wondering how this is evaluated. > > a=(x for x in [1,2,3,4]) > p=[4,5] > > c=[x for x in p if x in list(a)] > > c is [] > > but if I expand a first, like a = list(a) > > c is [4] > > So it seems that the "if" part don't get expanded ? Well, for every elemen

Re: Importing at runtime

2005-10-24 Thread Devan L
http://www.python.org/doc/2.4.2/lib/built-in-funcs.html or, if you want an answer in code now and don't want to read the docs def my_import(name): module = __import__(name) globals()[name] = module #not a good idea Or, seeing as how you won't be directly accessing them by name, anyways

Re: Importing Modules

2005-11-02 Thread Devan L
Sam Pointon wrote: > On the second point, a combination of sys.path, os.listdir and > __import__ should do what you're after, although sifting through the > whole of sys.path and subfolders from Python, rather than the > interpreter itself, could be slow. (And it'll be redundant as well - > __imp

Re: Cheapest pocket device to code python on

2005-11-03 Thread Devan L
[EMAIL PROTECTED] wrote: > What is the cheapest/affordable pocket device that I can code python > on? I think the closest I have seen is pocketpc from this page: > > http://www.murkworks.com/Research/Python/PocketPCPython/Overview I would not recommend trying to code on a handheld device. Small s

Is mod_python 3.1 good for commercial blogging/CMS?

2005-11-07 Thread Anthony L.
I am writing a web application that is comparable to a content management system used in blogging. I really want to use Python after having done some evaluation coding using Python 2.3.5 with mod_python 3.1.4 running on Apache 2.0 with the Publisher handler. However, I am still very hesitant to

Re: Underscores in Python numbers

2005-11-07 Thread Devan L
Gustav Hållberg wrote: > I tried finding a discussion around adding the possibility to have > optional underscores inside numbers in Python. This is a popular option > available in several "competing" scripting langauges, that I would love > to see in Python. > > Examples: > 1_234_567 > 0xdead_

Re: Is mod_python 3.1 good for commercial blogging/CMS?

2005-11-08 Thread Anthony L.
In article <[EMAIL PROTECTED]>, "Ben Sizer" <[EMAIL PROTECTED]> wrote: > Anthony L. wrote: > > 1. I want to use CGI through Publisher handler, instead of CGI handler > > or PSP. Despite the speed increase mod_python gives me, there is a > > proble

Re: Is mod_python 3.1 good for commercial blogging/CMS?

2005-11-08 Thread Anthony L.
In article <[EMAIL PROTECTED]>, Francois Lepoutre <[EMAIL PROTECTED]> wrote: > > 3. I am not very attracted to PSP because I want to separate the logic > > from the presentation as completely as possible [...] > > In view of your project why not consider cherrypy as well? It may > be an alte

Re: Is mod_python 3.1 good for commercial blogging/CMS?

2005-11-08 Thread Anthony L.
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (John J. Lee) wrote: > "Ben Sizer" <[EMAIL PROTECTED]> writes: > [...] > > It as not easy to work with the CGI-style code in a WYSIWYG web editor > > as it is to edit a template, which is probably the main reason for > > their use. Also, coding ev

Re: Command-line tool able to take multiple commands at one time?

2005-11-10 Thread Devan L
Peter A. Schott wrote: > Per subject - I realize I can copy/paste a line at a time into an interactive > session when I'm trying to debug, but was wondering if there is any tool out > there that allows me to copy sections of working Python scripts to paste into > my > interactive console and let

Re: Command-line tool able to take multiple commands at one time?

2005-11-11 Thread Devan L
Peter A. Schott wrote: > OK - I justed tested and may be doing something wrong, but it didn't work > when I > just tried it. > > I have something like this: > > X = "Value1" > Y = "Value2" > Z = "Value3" > > etc at the top of my script. When I copy/paste those three lines all at once > into IDLE'

Re: XUL behavior in Python via XPCOM, Mozilla

2005-11-12 Thread Devan L
Terry Hancock wrote: > I recently saw a claim that Mozilla XUL behaviors (normally > scripted in Javascript) can (or perhaps will) be scriptable > in Python. > > Also, "other languages such as Java or Python are supported > through XPCOM", said about Mozilla (from Luxor website). > > Yes, I know se

Re: Recursion bug...

2005-11-30 Thread Devan L
ex_ottoyuhr wrote: > To start with, I'm new at Python, so if this is something relatively > ordinary or a symptom of thinking in C++, I apologize... > > Anyhow, I'm currently trying to write a means of generating > genetic-programming functions in Python; the details would be a little > much for a

Re: How to execute an EXE via os.system() with spaces in the directory name?

2005-12-03 Thread Vijay L
I don't have any problems with spaces in the folders. just for debugging, you could probably try os.system(CMD.replace("\\", "/") On 3 Dec 2005 19:16:10 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I am trying to run an exe within a python script, but I'm having > trouble with spaces in

Re: join dictionaries using keys from one & values

2005-12-05 Thread Devan L
ProvoWallis wrote: > Thanks so much. I never would have been able to figure this out on my > own. > > def dictionary_join(one, two): > > dict2x = dict( ((dict2[k], k) for k in dict2.iterkeys())) > dict3 = dict(((k, dict2x[v]) for k,v in dict1.iteritems())) > print dict3 > > dict1 =

Re: what's wrong with "lambda x : print x/60,x%60"

2005-12-05 Thread Devan L
Steve Holden wrote: > [EMAIL PROTECTED] wrote: > > "Gary Herron" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>--snip-- > >>So just use a def. It is constantly pointed out on > >>this list that the lambda provides no extra expressive power, it is > >>merely a shortcut > >

MDaemon Warning - virus found: Error

2005-01-03 Thread l . cubells
*** WARNING ** Este mensaje ha sido analizado por MDaemon AntiVirus y ha encontrado un fichero anexo(s) infectado(s). Por favor revise el reporte de abajo. AttachmentVirus name Action taken ---

Re: what list comprehension can't

2005-06-24 Thread Devan L
I wasn't aware that python supported "if then else". -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-25 Thread Devan L
Why overload when you can use class methods? -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-25 Thread Devan L
But by using the builtin reduce, you need to specify a function, which probably slows it down more than any speed-up from the loop in C. -- http://mail.python.org/mailman/listinfo/python-list

Re: noob question

2005-06-25 Thread Devan L
To recognize variables that you have assigned, just look for assignment. If your code is readible, and you know it well, you shouldn't need the $ sign in front of everything. -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-06-26 Thread Devan L
< "return a if a.value == true" < "database.query(q) unless database.connect == error (etc) if a.value == True: return a if not database.connect == error: database.query(q) Trading two words for one word doesn't necessarily make the code better. < unless false then print 1 # this prints

Re: I need help figuring out how to fix this code.

2005-06-28 Thread Devan L
password = raw_input("Type in the password, please: ") while password != "hello": print "Incorrect password!" Wouldn't this print "Incorrect password" untill the end of time if you didn't supply the correct password? -- http://mail.python.org/mailman/listinfo/python-list

Re: regulars expressions ?

2005-06-28 Thread Devan L
re.findall(r'"?(.+?)"?(?:,|$)', yourtexthere) -- http://mail.python.org/mailman/listinfo/python-list

Re: regulars expressions ?

2005-06-28 Thread Devan L
Oh, oops, sorry, that code doesn't respect the quotes. Use this code: re.findall(r'(".+?"|\S+)(?:,|$)', yourtexthere) -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: Help Figger Out My Problem

2005-06-28 Thread Devan L
import random flips = 100 results = [random.randint(0,1) for i in range(flips)] heads = results.count(0) tails = results.count(1) print "Heads:%s" % heads print "Tails:%s" % tails I think this is more compact. -- http://mail.python.org/mailman/listinfo/python-list

Re: When someone from Britain speaks, Americans hear a "British accent"...

2005-06-28 Thread Devan L
Thats like posting about Google here because the newsgroup is hosted on Google. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python for everything?

2005-06-30 Thread Devan L
Python for everything except things that need to be ridiculously optimized for speed. Thats what C embedded in Python and Psyco enhanced Python code is for. Oh wait, thats still all Python... -- http://mail.python.org/mailman/listinfo/python-list

Re: class attribute to instance attribute

2005-06-30 Thread Devan L
Why make it an instance attribute? Couldn't you just look at the class attribute? If its something that depends on each instance's value assigned to the attribute, why not make it an instance attribute to start with? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run commands in command line from a script

2005-06-30 Thread Devan L
The code module, perhaps? http://www.python.org/doc/2.4.1/lib/module-code.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping commas within parens in CSV parsing?

2005-06-30 Thread Devan L
Try this. re.findall(r'(.+? \(.+?\))(?:,|$)',yourtexthere) -- http://mail.python.org/mailman/listinfo/python-list

Re: Escaping commas within parens in CSV parsing?

2005-06-30 Thread Devan L
Oops, the above code doesn't quite work. Use this one instead. re.findall(r'(.+? (?:\(.+?\))?)(?:,|$)',yourtexthere) -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting string into dictionary

2005-06-30 Thread Devan L
One line solution. dict(re.findall(r"'(.+?)' \| '(.+?)'(?:\s\||$)",yourtexthere)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expression for pattern substitution

2005-07-01 Thread Devan L
re.replace. I don't think there's any way to avoid it. Except maybe having an alias email address or a fake one. -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-01 Thread Devan L
None of them are really indispensible. Map and filter cab be replaced with list comprehensions. reduce is redundant except when multiplying a series; there's a sum function for a reason. Lambda looks cleaner in some cases, but you don't gain any functionality. What really struck me, though, is the

Re: Regular Expression for pattern substitution

2005-07-01 Thread Devan L
Hrm, thought it had one. Guess it would help if I actually used regular expression for replacement. -- http://mail.python.org/mailman/listinfo/python-list

Re: class attribute to instance attribute

2005-07-01 Thread Devan L
Well, I've never heard of a method like that for assigning variables. I'd rather put it in the __init__ method. -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-07-01 Thread Devan L
With the exception of reduce(lambda x,y:x*y, sequence), reduce can be replaced with sum, and Guido wants to add a product function. -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-02 Thread Devan L
Claiming that sum etc. do the same job is the whimper of someone who doesn't want to openly disagree with Guido. Could you give an example where sum cannot do the job(besides the previously mentioned product situation? Also, map is easily replaced. map(f1, sequence) == [f1(element) for element i

Re: Favorite non-python language trick?

2005-07-02 Thread Devan L
sum(sequence[0] + [1/element for element in sequence[1:]]) I think that should work. -- http://mail.python.org/mailman/listinfo/python-list

Re: Favorite non-python language trick?

2005-07-03 Thread Devan L
Okay, maybe that was too restrictive, reduce can *usually* be replaced with sum. Sorry about that. -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread Devan L
def flatten(iterable): if not hasattr(iterable, '__iter__'): return [iterable] return sum([flatten(element) for element in iterable],[]) Recursion makes things so much shorter. -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Devan L
> Here's a couple of examples from my own code: > > # from a Banzhaf Power Index calculator > # adds things that aren't numbers > return reduce(operator.add, > (VoteDistributionTable({0: 1, v: 1}) for v in electoral_votes)) return sum([VoteDistributionTable({0:1, v:1} for v in electoral_votes]

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Devan L
List comprehensions are faster than generator comprehensions for iterating over smaller sequences. -- http://mail.python.org/mailman/listinfo/python-list

Re: removing list comprehensions in Python 3.0

2005-07-08 Thread Devan L
>>> import timeit >>> t1 = timeit.Timer('list(i for i in xrange(10))') >>> t1.timeit() 27.267753024476576 >>> t2 = timeit.Timer('[i for i in xrange(10)]') >>> t2.timeit() 15.050426800054197 >>> t3 = timeit.Timer('list(i for i in xrange(100))') >>> t3.timeit() 117.61078097914682 >>> t4 = timeit.Time

Re: Yet Another Python Web Programming Question

2005-07-09 Thread Devan L
Take some time to learn one of the web frameworks. If your host doesn't already have it, ask your host if they would consider adding it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Forum

2005-07-09 Thread Devan L
I see a total of 12 posts and 8 users. -- http://mail.python.org/mailman/listinfo/python-list

Re: question on "input"

2005-07-12 Thread Devan L
Use raw_input instead. It returns a string of whatever was typed. Input expects a valid python expression. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
import re name = "Robert" f = file('phonebook.txt','r') lines = [line.rstrip("\n") for line in f.readlines()] pat = re.compile(name, re.I) related_lines = [line for line in lines if pat.search(line)] And then you write the lines in related_lines to a file. I don't really write text to files much s

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
How is this different from a nested function? -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
I think you need to get a database. Anyways, if anything, it should create no more than 5,000 files, since 5,000 facts shouldn't talk about 30,000 animals. There have been a few discussions about looking at files in directories though, if you want to look at those. -- http://mail.python.org/mailm

Re: Help with inverted dictionary

2005-07-12 Thread Devan L
Oh, I seem to have missed the part saying 'or other word'. Are you doing this for every single word in the file? -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
Well, the string that gets passed is more or less a function definition, which is then called with exec. I don't see why you'd need to write a string out with the function definition and then call it. You could just write the function. As for the nested functions, I had been presuming that it was

Re: automatically assigning names to indexes

2005-07-12 Thread Devan L
import math class Vector: def __init__(self, coordinates): self.coordinates = coordinates self.magnitude = sum([c**2 for c in coordinates])**0.5 self.direction = getangle(Vector([1]+[0 for i in range(len(coordinates)-1)])) def dotproduct(self, vector): sum([a

Re: Creating anonymous functions using eval

2005-07-12 Thread Devan L
> You missed Steven's point which is to quote the message to which you are > replying. Not everyone is reading this list in a conveniently threaded > form, so you need to provide some context for them to be able to follow > along. Ah, sorry, I didn't quite get what he was referring to. -- http:/

Re: Odd behaviour of regexp module

2005-07-13 Thread Devan L
Why doesn't group have an argument? group() or group(0) returns what the pattern matched, not what it returns. -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem loading a file of words

2005-07-24 Thread Devan L
teoryn wrote: > I've been spending today learning python and as an exercise I've ported > a program I wrote in java that unscrambles a word. Before describing > the problem, here's the code: > > *--beginning of file--* > #!/usr/bin/python > # Filename: unscram.py > > def sort_string(word): >

Re: Problem loading a file of words

2005-07-24 Thread Devan L
Robert Kern wrote: > That's definitely not the kind of dictionary that he wants. > > -- > Robert Kern > [EMAIL PROTECTED] > > "In the fields of hell where the grass grows high > Are the graves of dreams allowed to die." >-- Richard Harter Oh, I missed the part where he put values in a list

Re: A Module on Time & Date

2005-07-26 Thread Devan L
Robert Maas, see http://tinyurl.com/uh3t wrote: > > From: Robert Kern <[EMAIL PROTECTED]> > > As you can see in the datetime documentation, the module was introduced > > in Python 2.3. I recommend updating your Python installation. > > What do you mean "your"?? I don't have any Python installatio

Re: [pygame]how to copy a surface to an other surface with alpha value?

2005-07-26 Thread Devan L
flyaflya wrote: > I want to join some surfaces to a new big surface with alpha cannel, I want > the new surface has same pixels(inclue r,g,b and alpha value) as the pixels > on the source surfaces. > my code as follow: > > surf = pygame.Surface((200,200)) > surf.blit(surf1, (0,0)) > surf.blit(su

Re: searching string url

2005-07-27 Thread Devan L
Sounds somewhat like homework. So I won't just give you a code solution. Use the regular expression(re) module to match the urls. -- http://mail.python.org/mailman/listinfo/python-list

Re: Wheel-reinvention with Python

2005-08-01 Thread Devan L
Ed Leafe wrote: > On Sunday 31 July 2005 22:39, Paul Rubin wrote: > > > > import dabo > > > app = dabo.dApp() > > > dApp.start() > > > > > > Sorry, I couldn't do it in 5. ;-) Oh, and that includes a full menu, > > > too. > > > > I get an ImportError exception when I try that. Any suggestions? N

Re: Newbie Program

2005-08-04 Thread Devan L
Eric wrote: > I am reading a book on Python and ran across and exercise that I just > can't seem to figure out. Its pretty simple, but I just can't get > past a certain point. > > The task is to create a program that flips a coin 100 times and keeps > track of the total of heads and tails which is

Re: Fat and happy Pythonistas (was Re: Replacement for keyword 'global' good idea? ...)

2005-08-06 Thread Devan L
a report out that the "scripting languages" in general are > losing mindshare big time in Europe, Africa and the east in general. > In fact, everywhere except in North America. I'm generally somewhat > skeptical of these reports unless I can see the methodology, but it&#x

Re: Some newbie cgi form questions...

2005-08-07 Thread Devan L
googleboy wrote: > for key in form.keys():Yes, I know which fields are hidden because I > made them that way, but I am trying to figure out a way I can iterate > over the fields and do one thing with hidden fields (assign them to > variables that tell the form how to process) and a different th

Re: Help with Regular Expressions

2005-08-10 Thread Devan L
Harlin Seritt wrote: > I have been looking at the Python re module and have been trying to > make sense of a simple function that I'd like to do. However, no amount > of reading or googling has helped me with this. Forgive my > stone-headedness. I have done this with .NET and Java in the past but >

Re: sorting question

2005-08-10 Thread Devan L
Ksenia Marasanova wrote: > Hi, > > I have a list that contains nodes from a tree. Each node is a class > instance, but I'll use dictionary here to simplify the example. > So the list looks like this: > [ > {'id': 1, > 'name': 'Parent node', > 'ord_number': 1, > 'parent_id': 0, > 'url': '/parentnod

Re: Regular expression to match a #

2005-08-11 Thread Devan L
John Machin wrote: > Aahz wrote: > > In article <[EMAIL PROTECTED]>, > > John Machin <[EMAIL PROTECTED]> wrote: > > > >>Search for r'^something' can never be better/faster than match for > >>r'something', and with a dopey implementation of search [which Python's > >>re is NOT] it could be much wor

Re: Regular expression to match a #

2005-08-11 Thread Devan L
John Machin wrote: > Devan L wrote: > > John Machin wrote: > > > >>Aahz wrote: > >> > >>>In article <[EMAIL PROTECTED]>, > >>>John Machin <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>>

Re: How do these Java concepts translate to Python?

2005-08-11 Thread Devan L
Fausto Arinos Barbuto wrote: > Ray wrote: > > > 1. Where are the access specifiers? (public, protected, private) > > AFAIK, there is not such a thing in Python. > > ---Fausto Well, technically you can use _attribute to mangle it, but technically speaking, there are no public, protected, or pr

Re: NEWB: General purpose list iteration?

2005-08-11 Thread Devan L
def descend(iterable): if hasattr(iterable, '__iter__'): for element in iterable: descend(element) else: do_something(iterable) This will just do_something(object) to anything that is not an iterable. Only use it if all of your nested structures are of the same

Re: Dictionary inheritance

2005-08-12 Thread Devan L
Talin wrote: > I want to make a dictionary that acts like a class, in other words, > supports inheritance: If you attempt to find a key that isn't present, > it searches a "base" dictionary, which in turn searches its base, and so on. > > Now, I realize its fairly trivial to code something like thi

  1   2   3   4   5   6   7   >