Re: hard to explain for a french ;-)

2006-06-23 Thread Daniel Nogradi
d http://mail.python.org/pipermail/python-list/2006-June/348241.html what you try to do will never work because your attempts are at using python on the client side and only javascript works for that purpose. But for this popup thing javascript is just fine so if all you want to do is this then you don't need python at the first place. HTH, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: search engine

2006-06-24 Thread Daniel Nogradi
> hai all, > i am student of computer science dept. i have planned to > design a search engine in python. i am seeking info about how to > proceed further. > i need to know what r the modules that can be used. There are these two guys Sacha or Sergey and Larry (if I remember cor

Re: Questions about OSS projects.

2006-06-28 Thread Daniel Dittmar
hat warrants a library. This does not mean to simply package all the scripts into one package, but to see if there are any common tasks among the scripts to 'refactor' them into a library. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: for and while loops

2006-06-28 Thread Schüle Daniel
enerates a list with number [0,1,2 ... 99] and iterates through it one could write it like for i in [0,1,2,3,4]: do_something_with(i) but it gets tedious to write such a long list > > but im not quite grasping those functions.. > > please bear im mind i am an extreme newbie at this...thanks in advance > hth, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: delete first line in a file

2006-06-30 Thread Schüle Daniel
ne an print them on the screen! > but...how can i say python, delete the first line?! > thats my problem! > in the entry of my posting i wrote, that i am a newbie and so please > understand me, that i ask so questions?! :-) > > thanks for your help! simple! f = file("old.file") ignore = f.readline() file("new.file", "w+").write(f.read()) hth, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: string replace

2006-06-30 Thread Schüle Daniel
for now I use this >>> import re >>> chars = re.compile(r'[abc]') >>> text = "aAbBcCdD" >>> chars.sub("",text) 'ABCdD' >>> > > Thanks, > Michele Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: How to control permission of file?

2006-06-30 Thread Schüle Daniel
ants from stat module >>> import os >>> os.stat("/etc/shadow") (33184, 245390L, 771L, 1, 0, 15, 604L, 1151702662, 1149675585, 1149675585) >>> >>> import stat >>> stat.ST_SIZE 6 >>> os.stat("/etc/shadow")[stat.ST_SIZE] 604L >>> http://docs.python.org/lib/module-stat.html hth, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: How to control permission of file?

2006-06-30 Thread Schüle Daniel
ow level IO). >>> import os >>> fd=os.open("secret", os.O_WRONLY|os.O_CREAT, 0400) >>> os.write(fd,"not for everybody") 17 >>> os.close(fd) ls -l secret -r 1 root root 17 2006-07-01 00:05 secret Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there a Python __LINE__ ?

2006-07-06 Thread Daniel Nogradi
> Hi, > > is there a Python aquivalent to the C __LINE__? > > Thank you in advance Google says: http://www.nedbatchelder.com/blog/200410.html#e20041003T074926 -- http://mail.python.org/mailman/listinfo/python-list

Re: for loop question

2006-07-06 Thread Daniel Haus
just do: for a in range(2, foo+1): print a range(a, b) gives [a, a+1, a+2, ..., b-2, b-1] bruce schrieb: > hi.. > > basic foor/loop question.. > > i can do: > > for a in foo > print a > > if i want to do something like > for a, 2, foo > print foo > > where go from 2, to foo.. > >

Re: for loop question

2006-07-06 Thread Daniel Haus
> Except that in the OP's example foo was a sequence, not an > integer. I think. Yes, possibly. But then, what's "from 2 to foo"? this way it might be for a in [2] + foo: print a -- http://mail.python.org/mailman/listinfo/python-list

Re: array of array of float

2006-07-09 Thread Schüle Daniel
[EMAIL PROTECTED] schrieb: > i used C too much and haven't used Python for a while... > > like in C, if we want an array of array of float, we use > > float a[200][500]; > > now in Python, seems like we have to do something like > > a = [ [ ] ] * 200 > > and then just use > > a[1].append(12.3

Re: array of array of float

2006-07-09 Thread Schüle Daniel
Schüle Daniel schrieb: > [EMAIL PROTECTED] schrieb: >> i used C too much and haven't used Python for a while... >> >> like in C, if we want an array of array of float, we use >> >> float a[200][500]; >> >> now in Python, seems like we have to d

re question

2006-07-10 Thread Schüle Daniel
IGNORECASE. Is there a way to switch-off the option resp. switch-on the option in the middle of the pattern? Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Relying on the behaviour of empty container in conditional statements

2006-07-11 Thread Daniel Dittmar
t stand interpreting integers as booleans, so I wouldn't write if count: Everyone has their personal quirks. > > Note that I have much more experience with the language (6-7 years), > whilst the majority of my collegues have about 1-2 years experience. > I guess they're coming from Java and not from Perl :-) Daniel -- http://mail.python.org/mailman/listinfo/python-list

How to handle wrong input in getopt package in Python?

2006-08-25 Thread Daniel Mark
easily check the validity of each command line input parameter? Thank you -Daniel FYI: My code that deals with getopt is as follows: o, a = getopt.getopt(sys.argv[1:], 'h', ['imageDir=']) opts = {} for k,v in o: if k in ['--imageDir'] and len(v) == 0:

Re: Avoiding if..elsif statements

2006-08-25 Thread Daniel Nogradi
> Code: > > value = self.dictionary.get(keyword)[0] > > if value == "something": > somethingClass.func() > elsif value == "somethingElse": > somethingElseClass.func() > elsif value == "anotherthing": > anotherthingClass.func() > elsif value == "yetanotherthing": > yetanotherthingCla

Re: question about SOAPpy

2006-08-30 Thread Daniel O'Brien
wasn't viable. It looks like they've updated since then, so it may be worth re-evaluating. At present I use a heavily modified copy of SOAPpy. If anyone happens to have feedback regarding the above issues, I'd appreciate the input. Daniel O'Brien m.banaouas wrote: > H

Re: Libraries in python

2006-09-02 Thread Daniel Nogradi
> Hy people, I'm new in python and comming from JAVA. > > Something I really like in java is the easy way to add a library to the > project. Just put the jar file in the folder ( WEB-INF/lib ) and > doesn't need to restart the server ( tomcat ). > > Can I do some like using python - I'm using apach

Re: Managing database tables through web-forms (automatically)

2006-09-03 Thread Daniel Nogradi
> >> Check out Django, it has a great database API and on the fly > >> auto-generated admin. > > > > Just gone over the tutorial, really amazing, exactly what I need. > > That's exactly the response I had when I met with Django :) > Anyone with Django experience: how well does it do with respect t

Re: threading support in python

2006-09-04 Thread Daniel Dittmar
ction alone will break many Python applications (because they rely on files being closed at end of scope etc.) Daniel -- http://mail.python.org/mailman/listinfo/python-list

[ANN] markup.py 1.5 - a lightweight HTML/XML generator

2006-09-04 Thread Daniel Nogradi
thank all users especially those who sent bug reports, comments, remarks, etc., I was in fact surprised by the large amount of feedback I got this makes the developement much more fun. Cheers, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: threading support in python

2006-09-04 Thread Daniel Dittmar
Rob Williscroft wrote: > Daniel Dittmar wrote in news:[EMAIL PROTECTED] in > comp.lang.python: > > >>- removing reference counting and relying on garbage collection alone >>will break many Python applications (because they rely on files being >>closed at end of s

asyncore.dispatcher stops listening

2006-09-04 Thread Daniel Walton
I have been working on a problem for a full week now. If someone could please help me it would be great. Even a clue would be great at this point. What I am seeing is quite a mystery. I have server written in python using asyncore.dispatcher. It listens on port 9940 and does something like thi

Re: getting quick arp request

2006-09-07 Thread Daniel Nogradi
> 2) > Still without the above patch on windows, the software "angry ip scan" > for example managed to output a lot of more socket connection. How is > it possible ? This "angry ip scan" thing is written in Java, perhaps you can find it out from the source: http://svn.sourceforge.net/viewvc/ipsca

Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo
Hello everybody, I'm trying to implement a secure xmlrpc server with basis on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496786 recipe. The thing that I'm concerned about is how can I get/create rapidly the .pem files (the key and cert). Any help? Thanks Daniel

Re: Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo
l that stuff. Before getting involved in that, do you know of a faster way to have it installed? Thanks Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo
code I submited earlier, but I need the .pem files. You told me to change generate.sh to generate.bat. How can I do that? Many thanks, Daniel Laszlo Nagy wrote: > Daniel Crespo írta: > > Laszlo Nagy wrote: > > > >>> If you have OpenSSL installed, you can do the following:

Re: markup.py 1.5 - a lightweight HTML/XML generator

2006-09-12 Thread Daniel Nogradi
didn't know about this other project. Perhaps I should add a note to the webpage clarifying this. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Secure XMLRPC Server / PEM Files

2006-09-12 Thread Daniel Crespo
65064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:.\ crypto\evp\evp_enc.c:461: 3688:error:0906A065:PEM routines:PEM_do_header:bad decrypt:.\crypto\pem\pem_lib. c:425: Any help? Thanks in advance Daniel -- http://mail.python.org/mailman/listinfo/python-list

Resolved: Secure XMLRPC Server / PEM Files

2006-09-12 Thread Daniel Crespo
rm -f .rnd (for .bat, just ignore the last line and use "move" instead of "mv", "del" instead of "rm" and "yourdomain.com" instead of "$1") It will generate 4 files. Take the two with .pem extension, and put it on the same directory as the SecureXMLRPCServer code. 3. In order for get running the code, install pyOpenSSL available at http://pyopenssl.sourceforge.net/. For Windows you may prefer http://webcleaner.sourceforge.net/pyOpenSSL-0.6.win32-py2.4.exe That's it. Special thanks to Laszlo Nagy Enjoy! Daniel Crespo -- http://mail.python.org/mailman/listinfo/python-list

something for itertools

2006-09-15 Thread Daniel Nogradi
In a recent thread, http://mail.python.org/pipermail/python-list/2006-September/361512.html, a couple of very useful and enlightening itertools examples were given and was wondering if my problem also can be solved in an elegant way by itertools. I have a bunch of tuples with varying lengths and w

How to change font direction?

2006-09-15 Thread Daniel Mark
Hello all: I am using PIL to draw some graphics and I need to draw some texts in vertical direction rather than the default left-to-right horizontal direction. Is there anyway I could do that? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: something for itertools

2006-09-15 Thread Daniel Nogradi
> > In a recent thread, > > http://mail.python.org/pipermail/python-list/2006-September/361512.html, > > a couple of very useful and enlightening itertools examples were given > > and was wondering if my problem also can be solved in an elegant way > > by itertools. > > > > I have a bunch of tuples

Re: something for itertools

2006-09-16 Thread Daniel Nogradi
> > In a recent thread, > > http://mail.python.org/pipermail/python-list/2006-September/361512.html, > > a couple of very useful and enlightening itertools examples were given > > and was wondering if my problem also can be solved in an elegant way > > by itertools. > > > > I have a bunch of tuples

How to draw a rectangle with gradient?

2006-09-16 Thread Daniel Mark
Hello all: I am using PIL to draw a rectangle filled with color blue. Is there anyway I could set the fill pattern so that the drawn rectangle could be filled with gradient blue? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythondocs.info : collaborative Python documentation project

2006-09-16 Thread Daniel Nogradi
> Everytime I am lookink at how to do this or that in Python I write it > down somewhere on my computer. (For ex. Threading. After reading the > official documentation I was a bit perplex. Hopefully I found an > article an managed to implement threads with only like 20 lines of code > in my script.

Re: Pythondocs.info : collaborative Python documentation project

2006-09-17 Thread Daniel Nogradi
> > > That said...the Python docs are open source. Just start going through > > > them and adding examples. > > > > ASPN (activestate) is a good place for examples... > > Yes, but that requires a separate search and depends on an external > organization. Wouldn't it be great if relevant examples we

How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Daniel Mark
Hello all: I have a list AAA = [1, 2, 3] and would like to subtract one from list AAA so AAA' = [0, 1, 2] What should I do? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python on a 64-Bit OS

2006-09-19 Thread Daniel Dittmar
eate wrapper scripts for the compiler (and possibly ld and ar), which uses the proper options. Add the location of these scripts at the start of PATH, thus overiding the compiler. Now all configures will default to 64 bit. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Do we need to delete "ImageDraw.Draw" after using it?

2006-09-20 Thread Daniel Mark
m.size, fill=128) draw.line((0, im.size[1], im.size[0], 0), fill=128) del draw # ===>>>> Why we should delete this object draw? # write to stdout im.save(sys.stdout, "PNG") # Is there any general rule that we must delete the obje

How to evaluate the memory usage of a python program?

2006-09-20 Thread Daniel Mark
Hello all: I have a python program and would like to find out the maximum memory used by this program. Does Python provide such module so I could check it easily? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

How does IPython modify the sys.path?

2006-09-21 Thread Daniel Mark
Hello all: I installed IPython on my XP machine today and find that my sys.path has been changed as follows: >> import sys >> print sys.path ['', 'C:\\Program Files\\Python24\\scripts', 'C:\\WINDOWS\\system32\\python24.zip', 'C:\\Documents and

Does Python provide "Struct" data structure?

2006-09-22 Thread Daniel Mark
ld console=['mycode.py'], ) ####### Does I need to make any modification if I include IPython module in my code? Thank you for your helps -Daniel -- http://mail.python.org/mailman/listinfo/python-list

Question about the article "py2exe compiler" in Python Cookbook by Alexander Semenov

2006-09-22 Thread Daniel Mark
o to solve this problem? Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

How to save High Quality JPG image by setting Image module from PIL

2006-09-25 Thread Daniel Mark
hello all: I am using Image module from PIL to save created image as JPG format. Is there any option I could set for function Image.save so that the stored image will have the highest quality. Thank you -Daniel -- http://mail.python.org/mailman/listinfo/python-list

remove the last character or the newline character?

2006-09-28 Thread Daniel Mark
remove the last character of a string? I don't know whether or not the method I used is efficient Question two: Does python provide any function that can remove the newline character from a string if it exists? Thank very much! -Daniel -- http://mail.python.org/mailman/listinfo/python-list

loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
Is looping over a list of objects and modifying (adding an attribute to) each item only possible like this? mylist = [ obj1, obj2, obj3 ] for i in xrange( len( mylist ) ): mylist[i].newattribute = 'new value' I'm guessing there is a way to do this without introducing the (in principle unnec

Re: loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
> Is looping over a list of objects and modifying (adding an attribute > to) each item only possible like this? > > mylist = [ obj1, obj2, obj3 ] > > for i in xrange( len( mylist ) ): > mylist[i].newattribute = 'new value' > > > I'm guessing there is a way to do this without introducing the (in

Re: loop over list and modify in place

2006-09-30 Thread Daniel Nogradi
> Call me crazy, but isn't the simple construct > for obj in mylist: > obj.newattribute = 'new value' > what the OP was looking for? Yes, of course. That's why my follow-up post was this: > Please consider the previous question as an arbitrary random brain > cell fluctuation whose pro

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Daniel Nogradi
> > > Below is a simple program that will cause python to intermittently > > > stop executing for a few seconds. it's 100% reproducible on my > > > machine. > > > > Confirmed with Python 2.4.2 on Windows. > > > > gc.disable() fixes it, so it looks like you found an inefficiency in the > > Python's

app with standalone gui and web interface

2006-10-02 Thread Daniel Nogradi
What would the simplest way to make an application that has both a web interface and runs from behind a web server but also can be used as a standalone app with a gui? More precisely is it possible to avoid creating an html/xml/whatever based web interface for the web version and separately creatin

Re: app with standalone gui and web interface

2006-10-03 Thread Daniel Nogradi
> > What would the simplest way to make an application that has both a web > > interface and runs from behind a web server but also can be used as a > > standalone app with a gui? More precisely is it possible to avoid > > creating an html/xml/whatever based web interface for the web version > > an

Having trouble converting popen2 to subprocess

2006-11-18 Thread Daniel Klein
size=-1, stdin=PIPE, stdout=PIPE, universal_newlines=True) fin = p.stdin print fin.readline() fin.close() When this is run, I get no output : C:\>python c:\python\sp.py C:\> As you can see, I get no exception. I've tried various combinations of the Popen arguments with no joy. The platform

Re: Having trouble converting popen2 to subprocess

2006-11-18 Thread Daniel Klein
Thanks /F, that was it. Dan On Sat, 18 Nov 2006 15:03:30 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote: [snip] >p.stdin is the *other* process' stdin. if you want to read things it >prints, read from p.stdout instead. > >> print fin.readline() >> fin.close() > > -- http://mail.python.org/m

text file parsing (awk -> python)

2006-11-22 Thread Daniel Nogradi
Hi list, I have an awk program that parses a text file which I would like to rewrite in python. The text file has multi-line records separated by empty lines and each single-line field has two subfields: node 10 x -1 y 1 node 11 x -2 y 1 node 12 x -3 y 1 and this I would like to parse into a l

Re: text file parsing (awk -> python)

2006-11-22 Thread Daniel Nogradi
StringIO > return StringIO(data) > > converters = dict( > x=int, > y=int > ) > > def name_value(line): > name, value = line.split(None, 1) > return name, converters.get(name, str.rstrip)(value) > > if __name__ == "__main__": >

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

2006-11-23 Thread Daniel Austria
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 daniel -- http://mail.python.org/mailman/listinfo/python-list

'locals' argument of PyEval_EvalCode

2006-11-28 Thread Daniel Trstenjak
ifferent for the two following code lines: from modul import symbol from modul import * In the case of the first one, it's enough if the object 'locals' implements the necessary protocols. The second one only works if the object 'locals' is a type or subtype of dic

Re: How to detect what type a variable is?

2006-11-29 Thread Daniel Klein
tList) == "": > >and >if type(artistList) == "list": > >but nothing.. Try it this way... >>> artistList = [] >>> isinstance(artistList, list) True >>> if isinstance(artistList, list): print "I'm a list." I'm a list. >>> Daniel Klein -- http://mail.python.org/mailman/listinfo/python-list

Win32 Excel Generation Slow

2006-12-01 Thread Daniel Bowett
I am trying to create an excel document that displays a table of data. It does exactly what I want but takes a long time. I am writing around 1000 rows and it takes around a second to do each row. Is there a quicker way to write this? The reason I want excel is this needs to read and manipulate

Re: Is python memory shared between theads?

2006-12-01 Thread Daniel Dittmar
c and you pass the same dictionary as the globals argument to execfile, then the two scripts would share the global namespace. Variables of the same name would really be the same variable. Daniel -- http://mail.python.org/mailman/listinfo/python-list

how to convert a function into generator?

2006-12-06 Thread Schüle Daniel
Traceback (most recent call last) /pool/PROG/python/permute/ in () : I don't understand why the generator x raises StopIteration exception I would expect that x.next() would call permute(("a",), 4) and would stop at "abcd" thanks in advance regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Common Python Idioms

2006-12-07 Thread Daniel Dittmar
d he was right: import sys 'sys' in sys.modules => True sys in sys.modules => False Doesn't this look wrong? Daniel -- http://mail.python.org/mailman/listinfo/python-list

why is this different?

2006-12-08 Thread Schüle Daniel
]: def d(x): : return lambda:x : In [55]: f = [d(i) for i in range(10)] In [56]: f[0]() Out[56]: 0 In [57]: f[1]() Out[57]: 1 in a C programmer sence I would say there seems to be no "sequence point" which would separate "now" from "next" Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Common Python Idioms

2006-12-08 Thread Daniel Dittmar
he got mixed up with a crowd of ex C++ programmers). Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: why is this different?

2006-12-08 Thread Schüle Daniel
Gabriel Genellina schrieb: Gabriel Genellina schrieb: > On 7 dic, 22:53, Schüle Daniel <[EMAIL PROTECTED]> wrote: > >> In [38]: f = [lambda:i for i in range(10)] >> In [39]: ff = map(lambda i: lambda : i, range(10)) >> In [40]: f[0]() >> Out[40]: 9 >> In

Re: Common Python Idioms

2006-12-08 Thread Daniel Dittmar
r strings happens in my code only when a pass a string where I should have passed a list of strings. Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: skip last line in loops

2006-12-15 Thread Daniel Klein
On 14 Dec 2006 22:47:23 -0800, [EMAIL PROTECTED] wrote: >hi, >how can i skip printing the last line using loops (for /while) > >eg > >for line in open("file): > print line. > >I want to skip printing last line of the file.thanks while True: line1 = myfile.readline() if not line1: brea

module wide metaclass for new style classes

2006-12-16 Thread Daniel Nogradi
I used to have the following code to collect all (old style) class names defined in the current module to a list called reg: def meta( reg ): def _meta( name, bases, dictionary ): reg.append( name ) return _meta reg = [ ] __metaclass__ = meta( reg ) class c1: pass class c2:

Re: module wide metaclass for new style classes

2006-12-17 Thread Daniel Nogradi
> > I used to have the following code to collect all (old style) class > > names defined in the current module to a list called reg: > > > > > > def meta( reg ): > > def _meta( name, bases, dictionary ): > > reg.append( name ) > > return _meta > > > > reg = [ ] > > __metaclass__ = m

Re: popen on windows

2006-12-29 Thread Daniel Klein
On 27 Dec 2006 09:16:53 -0800, "hubritic" <[EMAIL PROTECTED]> wrote: >I am trying to set off commands on Windows 2003 from python. >Specifically, I am trying to use diskpart with a script file (pointed >to with path). > >cmd = ["diskpart", "/s", path] >p = Popen(cmd, shell

Re: Some basic newbie questions...

2006-12-29 Thread Daniel Klein
On 28 Dec 2006 08:40:02 -0800, "jonathan.beckett" <[EMAIL PROTECTED]> wrote: >Hi all, > >Question 2... >What is the correct way of looping through a list object in a class via >a method of it? Without peeking at any of the other responses, here is what I came up with. I hope it helps... class G

Re: How do I add users using Python scripts on a Linux machine

2007-01-01 Thread Daniel Klein
On 1 Jan 2007 11:33:42 -0800, "Ramdas" <[EMAIL PROTECTED]> wrote: >How do I add users using Python scripts on a Linux machine? > >Someone has a script? This should be as easy as something like: os.system("/usr/sbin/useradd -m -d /home/newuser -s /bin/ksh") Dan -- http://mail.python.org/mailman

Re: newbieee

2007-01-08 Thread Daniel Klein
On 8 Jan 2007 10:59:23 -0800, "Thomas Nelson" <[EMAIL PROTECTED]> wrote: >O'reilly has a book called Programming Python that covers much of the >standard library and how to use it for complex tasks. It may be out of >date by now, though. Programming Python (by Mark Lutz) is now in it's 3rd edi

generating method names 'dynamically'

2006-01-26 Thread Daniel Nogradi
Is it possible to have method names of a class generated somehow dynamically? More precisely, at the time of writing a program that contains a class definition I don't know what the names of its callable methods should be. I have entries stored in a database that are changing from time to time and

Re: generating method names 'dynamically'

2006-01-26 Thread Daniel Nogradi
> > Is it possible to have method names of a class generated somehow > dynamically? > > > > More precisely, at the time of writing a program that contains a class > > definition I don't know what the names of its callable methods should > > be. I have entries stored in a database that are changing

Re: generating method names 'dynamically'

2006-01-26 Thread Daniel Nogradi
> > My database has 1 table with 2 fields, one called 'name' and the other > > one called 'age', let's suppose it has the following content, but this > > content keeps changing: > > > > Alice 25 > > Bob 24 > > > > --- program1.py > > > > class klass: > > > > # do the

Re: generating method names 'dynamically'

2006-01-26 Thread Daniel Nogradi
> Here you go: > > >>> database = { > ... "Alice": 24, > ... "Bob":25} > ... > >>> class Lookup(object): > ... def __catcher(self, name): > ... try: > ... print "Hello my name is %s and I'm %s" % (name, > database[name]) > ... except KeyErro

Re: generating method names 'dynamically'

2006-01-27 Thread Daniel Nogradi
> Ouch! This certainly seems like a possible security hole! > > As someone else said, use rewrite rules to get this passed > in as a parameter. I don't get it, why is it more safe to accept GET variables than method names? Concretely, why is the URL http://something.com/script?q=parameter safer th

Re: generating method names 'dynamically'

2006-01-27 Thread Daniel Nogradi
> *>* I don't get it, why is it more safe to accept GET variables than > *>* method names? Concretely, why is the URL > *>* http://something.com/script?q=parameter safer than > *>* http://something.com/script/parameter if in both cases exactly the > *>* same things are happening with 'parameter'? >

backreference in regexp

2006-01-31 Thread Schüle Daniel
#x27; returns None but I would expect it to find 123 in group(1) Am I using something that is not supported by Python RegExp engine or what is the problem with my regexp? Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: backreference in regexp

2006-01-31 Thread Schüle Daniel
thank you, I completely forgot that + is one of metacharacters Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Sharing database connection from C to Python

2006-02-01 Thread Daniel Dittmar
that handle or pointer Or add a method to the Python MySQL object to get the handle and pointer. Create all database connections in Python (precise: using the Python API from C), get the handle and pointer to use it from C, pass the original session to plugins. Daniel -- http://mail.python.org/mailman/listinfo/python-list

OO conventions

2006-02-01 Thread Daniel Nogradi
I'm relatively new to object oriented programming, so get confused about its usage once in a while. Suppose there is a class Image that has a number of methods, rotate, open, verify, read, close, etc. Then to use this class my natural guess would be to have something like image = Image( ) image.re

Re: OO conventions

2006-02-01 Thread Daniel Nogradi
> > In this case, Image seems to be a python module, with the open function > defined, PIL's Image is not a class. > Thanks for the enlightening remarks, especially this last one, indeed, it's not a class. -- http://mail.python.org/mailman/listinfo/python-list

Re: OO conventions

2006-02-02 Thread Daniel Nogradi
> > > In this case, Image seems to be a python module, with the open function > > > defined, PIL's Image is not a class. > > > > > > > Thanks for the enlightening remarks, especially this last one, indeed, > > it's not a class. > > Actually, this way of creating a class instance is good OO practice

Re: OO conventions

2006-02-04 Thread Daniel Nogradi
> > Actually, this way of creating a class instance is good OO practice in > > many places: The Image.open() method acts as a factory-function for > > creating Image objects. > > You don't know, until you inspect the return value, if the created > > object is actually an instance of class Image or

Re: Numeric and matlab

2006-02-05 Thread Schüle Daniel
arange(0,11,.5) >>> filter(lambda x: x!=0, a) [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5] >>> [item for item in a if item !=0 ] [0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, 10.5] Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: OO conventions

2006-02-06 Thread Daniel Nogradi
> > So after all, what is a 'factory' or 'factory function'? > > A brief explanation in Python terms is at > http://www.aleax.it/ep03_pydp.pdf -- "pages" (slides) 37-44 (the rest of > the presentation is about an even more fundamental design pattern, > "template method"). A far more extensive essa

Re: read file problem

2006-02-06 Thread Schüle Daniel
if you want the numbers you can combine it into one-liner nums = file(r"C:\folder\myFile.txt").read().split(";") the numbers are in string representation in the list you can no do nums = [float(num) for num in nums] Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: Size of list

2006-02-06 Thread Schüle Daniel
lf): ... print "this instance has __len__" ... return 100 ... >>> x=X() >>> len(x) this instance has __len__ 100 >>> x.__len__() this instance has __len__ 100 hth, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: * 'struct-like' list *

2006-02-06 Thread Schüle Daniel
: xxx Age Id: 43324 OtherInfo: foo New here you could read all as string and split it on "New" here small example >>> txt = "fooXbarXfoobar" >>> txt.split("X") ['foo', 'bar', 'foobar'] >>> in more complicated case I would use regexp but I doubt this is neccessary in your case Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: how to copy a Python object

2006-02-07 Thread Schüle Daniel
eturn "lst has id = %i" % id(self.lst) ... def copy(self): ... ret = Y() ... ret.lst = self.lst[:] ... return ret ... >>> from random import randint >>> y=Y() >>> y.fill() >>> y lst has id = 1078097452 >>> print

Re: * 'struct-like' list *

2006-02-07 Thread Schüle Daniel
() if number.match(line)] fire interactive python and play with re and patterns speaking from own experience ... the propability is against you that you will make pattern right on first time Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list

UnboundMethodType and MethodType

2006-02-07 Thread Schüle Daniel
gt;> type(q.bar) is types.UnboundMethodType True >>> q.bar > >>> I think is not very consistent notice q.bar is bounded although type(q.bar) says it's types.UnboundedMethodType what do you think? Regard, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Re: UnboundMethodType and MethodType

2006-02-08 Thread Schüle Daniel
;> y = Q("test").bar >>> x >>> y > >>> y() test >>> id(x) 1078081812 >>> id(y) 1078082492 >>> the same id-value would enforce two objects to be of the same type (trivial case) the reverse is not necessarily true

pythonic exec* spawn*

2006-02-09 Thread Daniel Nogradi
Is it possible to pass a python object to a python program as argument? In my program I would like to start executing an other python program and don't wait until that finishes, only launch it and keep running the original program. The obvious way I can think of it is using the exec* or spawn* fun

Re: pythonic exec* spawn*

2006-02-09 Thread Daniel Nogradi
> >I would like to pass the whole object at once to the second python > >program which should start doing its thing with it while the original > >program should keep running. > > os.fork() does that (on Mac and Unix). > Okay, but how? It seems to me that if the process which issued os.fork() ends,

Re: pythonic exec* spawn*

2006-02-10 Thread Daniel Nogradi
> >> os.fork() does that (on Mac and Unix). > > > >Okay, but how? > > Sorry, fork() is implemented strictly on a 'need to know' basis :-) > > >It seems to me that if the process which issued os.fork() ends, then > >the forked process also ends. > > No, no, they're not a quantum mechanic photon pair

<    3   4   5   6   7   8   9   10   11   12   >