Re: doctest, unittest, or if __name__='__main__'

2006-03-22 Thread Max M
[EMAIL PROTECTED] wrote: >>and you can kill two birds with one stone. > > > By that, do you mean you can write your tests and your > docstrings in one shot with doctest? Exactly. >>> '\n'.join(['Doctests are absolutely brilliant!'] * 100) They combine two brilliant ideas that are hard to d

Re: TypeError coercing to Unicode with field read from XML file

2006-03-22 Thread Fredrik Lundh
Randall Parker wrote: > I'm probably doing something dumb as I've never done XML in Python > before. Any ideas what? using minidom ? ;-) if you're not wedded to minidom, there are alternatives that are easier to use for things like this. here's an ElementTree version of your code: ConfigTr

Re: markup.py - HTML/XML generator

2006-03-22 Thread Fredrik Lundh
Gerard Flanagan wrote: > Now I can do this: > > page = HtmlPage('Test Page') > navbar = page.div(id='left').ul(css='navbar') > for href,link in {'/home':'Home', '/shop':'Shop', > '/cart':'Cart'}.iteritems(): > navbar.li.a(link,href=href) > page.div(id='main').h1('Header').p

Re: String comparison question

2006-03-22 Thread Fredrik Lundh
Michael Spencer wrote: > a.split() == b.split() is a convenient test, provided you want to normalize > whitespace rather than ignore it. I took the OP's requirements to mean that > 'A B' == 'AB', but this is just a guess. I'm sure someone has studied this in more detail, but intuitively, parti

Re: From Python to c++

2006-03-22 Thread Marco Aschwanden
On Wed, 22 Mar 2006 08:11:24 +0100, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > This is so scary, I probably shouldn't post this. It sounds from your > description, you really want RTTI. I haven't done this in a long > while, so I'm not sure there is an easier way. But the program below >

How to kill/stop a Thread?

2006-03-22 Thread Dirk Zimmermann
Hi, I like to do the following: Via http I get a stream of data and I like to store this data with a python program. So what I need is to start the downloading and to stop it after a given time. My aproach was to use: urllib.urlretrieve("ULR","FILENAME") It is fine! But how to stop the retrie

Re: From Python to c++

2006-03-22 Thread Marco Aschwanden
Heck! I received 1 useless answer in comp.lang.c++ and here I get useful links/hints and even a code-pattern! Great. Thank you all. Sorry for posting a c++-problem here, but it was derived from my thinking the Python way... Cheers, Marco -- http://mail.python.org/mailman/listinfo/python-li

Re: How to kill/stop a Thread?

2006-03-22 Thread Fredrik Lundh
Dirk Zimmermann wrote: > I like to do the following: Via http I get a stream of data and I like > to store this data with a python program. So what I need is to start the > downloading and to stop it after a given time. My aproach was to use: > urllib.urlretrieve("ULR","FILENAME") > > It is fi

Re: py web-app-frameworks without a rdbms...

2006-03-22 Thread Anand
Try web.py. Very simple and powerful web framework. http://webpy.org -anand -- http://mail.python.org/mailman/listinfo/python-list

Re: ** Operator

2006-03-22 Thread Christoph Zwerschke
Georg Brandl wrote: > Had I seen the tracker item and/or read this thread to the end before I made > that checkin, I probably wouldn't have made it... ;) But then we would have never known that the Python gods are only people ;-) -- http://mail.python.org/mailman/listinfo/python-list

multiple assignment

2006-03-22 Thread Anand
Suppose i have a big list and i want to take tke the first one and rest of the list like car/cdr in lisp. is there any easy way to do this in python? Only way i know is a = range(10) x, y = a[0], a[1:] In perl, it is possible to do multiple assignment like this @a = (1, 2, 3); ($x, @y) = @

Re: py web-app-frameworks without a rdbms...

2006-03-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Of TurboGers & Django WAF candidates, which one would be easier to use > in an environment where the data/content doesn't come an RDBMS, but > from other server-side apps... Django is trivial to use for this (but you still want to use a DB together with the built-in adm

Re: Using yacas within Python for symbolis computation

2006-03-22 Thread JCDenton
No I am actually not :) Mudcat wrote: > Out of curiosity, are you also Texas Longhorn JCDenton in another > online life? -- http://mail.python.org/mailman/listinfo/python-list

Re: Which GUI toolkit is THE best?

2006-03-22 Thread Piet van Oostrum
> Michael Ekstrand <[EMAIL PROTECTED]> (ME) wrote: >ME> I've used both wxPython and PyGTK. I find wxPython to be horribly >ME> un-pythonic; combining that some problems on the Mac, and some >ME> other installation/environment issues, I ditched it for PyGTK. But AFAIK GTK doesn't have a native

Re: markup.py - HTML/XML generator

2006-03-22 Thread Gerard Flanagan
Fredrik Lundh wrote: > Gerard Flanagan wrote: > > > Now I can do this: > > > > page = HtmlPage('Test Page') > > navbar = page.div(id='left').ul(css='navbar') > > for href,link in {'/home':'Home', '/shop':'Shop', > > '/cart':'Cart'}.iteritems(): > > navbar.li.a(link,href=href) >

Re: multiple assignment

2006-03-22 Thread Christoph Zwerschke
Anand schrieb: > Suppose i have a big list and i want to take tke the first one and rest > of the list like car/cdr in lisp. > is there any easy way to do this in python? > > Only way i know is > > a = range(10) > x, y = a[0], a[1:] You have so many higher-level ways to access and iterate throug

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Julien Fiore
Thanks for the psyco information, Serge. > 2) Rewrite the code to be vectorized (don't use psyco) Right now your > code *doesn't* get any speed benefit from numpy I do not understand this point. How to rewrite the code ? Do you mean in C ? Julien -- http://mail.python.org/mailman/listinfo/pyth

Re: multiple assignment

2006-03-22 Thread Fredrik Lundh
Christoph Zwerschke wrote: > You're right, that would not be so far off. > But then, the following should be also supported: > > *x, y = a # x, y = a[:-1], y = a[-1] > x, *y, z = a # x, y, z = a[0], a[1:-1], a[-1] > > Of course, there can be only one variable with an asterisk. > (But note that in

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Julien Fiore
Thanks Caleb for the advice, I profiled my code with the following lines: import profile, pstats profile.runctx('openness(infile,outfile,R)',globals(),locals(),'profile.log') p = pstats.Stats('profile.log') p.sort_stats('time') p.print_stats(10) The outputs tells me that the ope

Re: Multifile EOF error

2006-03-22 Thread [EMAIL PROTECTED]
> Try to trim down your script to the minimal code that produces the error > and post both. Copy'n'paste code and traceback, don't retype it. The code is kinda bit long so you can see the whole idea. I use some libgmail and twisted web #code start def displayComment(request): gmc = libgmail.G

Using MAPI (simplemapi.py)

2006-03-22 Thread Tomas Brabenec
Hi all, i need open new messages in default e-mail client from my application in windows. I using simplemapi.py (http://www.kirbyfooty.com/simplemapi.py) But not worked correctly. This is a error message: Traceback (most recent call last): File "Q:\Notebook\frmApp.py", line 206, in on_mnu_ema

Per instance descriptors ?

2006-03-22 Thread bruno at modulix
Hi I'm currently playing with some (possibly weird...) code, and I'd have a use for per-instance descriptors, ie (dummy code): class DummyDescriptor(object): def __get__(self, obj, objtype=None): if obj is None: return self return getattr(obj, 'bar', 'no bar') class MyClass1(obje

Re: Importing two module variables and having one clobber the other?

2006-03-22 Thread Mike Mazurek
You could wrap your paramter dict in a class instance with something like:class Parameters(object):    def __init__(self, parameterDict):    self.__dict__ = parameterDict.copy()    # NB: copying may not be necissary for your case parms = Parameters(dict(a=1,b=2,c=3))print parms.a, parms.b,

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Dinko Tenev
funkyj wrote: > How about the other iterator characteristics? > > when there is a huge solution space can I ask the prolog version to > give me the first 1000 solutions? Geoffrey's post above offers one way to do this from within a REPL. Within a program, as soon as you accept a solution, you're

Default/editable string to raw_input

2006-03-22 Thread Paraic Gallagher
Hi, This is my first post to the list, I hope somebody can help me with this problem. Apologies if it has been posted before but I have been internet searching to no avail. What I am trying to do is provide a simple method for a user to change a config file, for a test suite. The config file c

Re: Which GUI toolkit is THE best?

2006-03-22 Thread Renato
Hardly a showstopper: gtk works now (with X11), and will work even better soon (native). :-) -- Ciao, Renato -- http://mail.python.org/mailman/listinfo/python-list

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Dinko Tenev
OK, here's a case that will make your program run in exponential time: S = { a, b }, W = { *a*b, *b*a } -- on my machine, it starts getting ugly as soon as n is 15 or so. Note that S^n - W = { a^n, b^n }. In general, whenever all the patterns in the set match against the last position, your curre

RE: From Python to c++

2006-03-22 Thread Ames Andreas
Hello Marco, > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > g] On Behalf Of Marco Aschwanden > Sent: Tuesday, March 21, 2006 8:43 PM > Subject: From Python to c++ > > parsed = { > "name":["Mac", "Mike"], > "age":[25, 55], > "place":["Zurich", "Oslo"]

Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread EdWhyatt
Hi all, I have searched the group with no answer to this particular problem. In my sendmail program, I would like to have the ability to send a mail message with no-one email address in the To field. I do this by adding the mail to the CC field via a header. However, by the time I get to the poin

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread Tim Williams (gmail)
On 22 Mar 2006 03:18:41 -0800, EdWhyatt < [EMAIL PROTECTED]> wrote: Hi all, I have searched the group with no answer to this particularproblem.In my sendmail program, I would like to have the ability to send a mailmessage with no-one email address in the To field. I do this by adding the mail to th

Some info

2006-03-22 Thread Fulvio
Hello, I'm very new of Python programming. I just wrote some hundred lines of a programm. Now, I'd like to go some step farther and make a disk cataloger. There are plenty for win, but few for linux. So, I'd like to write one which is for win and linux. I'm, actually, a bit stuck on how to coll

roobtic

2006-03-22 Thread sonercafri
http://www.sanalmerkez.gq.nu -- http://mail.python.org/mailman/listinfo/python-list

Re: Python vs. Java gzip performance

2006-03-22 Thread Felipe Almeida Lessa
Em Qua, 2006-03-22 às 00:47 +0100, "Martin v. Löwis" escreveu: > Caleb Hattingh wrote: > > What does ".readlines()" do differently that makes it so much slower > > than ".read().splitlines(True)"? To me, the "one obvious way to do it" > > is ".readlines()". [snip] > Anyway, decompressing the entir

Re: py web-app-frameworks without a rdbms...

2006-03-22 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Hi folks, > > Of TurboGers & Django WAF candidates, which one would be easier to use > in an environment where the data/content doesn't come an RDBMS, but > from other server-side apps... IMHO, both. > If these are not good candidates, could > you suggest appropriate

Re: Some info

2006-03-22 Thread Sybren Stuvel
Fulvio enlightened us with: > Now, I'd like to go some step farther and make a disk cataloger. What kind of disk? Harddisks? DVDs? Audio CDs? > I'm, actually, a bit stuck on how to collect informations regarding > disk names (CDroms or USB HDs). Depends on what names you want. Filenames? Track n

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Kent Johnson
Julien Fiore wrote: > Thanks Caleb for the advice, > > I profiled my code with the following lines: > > import profile, pstats > > profile.runctx('openness(infile,outfile,R)',globals(),locals(),'profile.log') > p = pstats.Stats('profile.log') > p.sort_stats('time') > p.print_stat

Re: Default/editable string to raw_input

2006-03-22 Thread Sybren Stuvel
Paraic Gallagher enlightened us with: > What I am trying to do is provide a simple method for a user to > change a config file, for a test suite. My opinion: let the user edit the configuration file using his/her favourite text editor. Someone configuring a test suite should certainly be able to e

Re: Some info

2006-03-22 Thread Fulvio
Alle 21:22, mercoledì 22 marzo 2006, Sybren Stuvel ha scritto: > > disk names (CDroms or USB HDs). > > Depends on what names you want. It seems clear that was _disk_ names. If isn't to much would be also useful to know the serial number, so will avoid to record a disk twice. On Win, we can call

struct size confusion:

2006-03-22 Thread Michael Yanowitz
Hello: I am relatively new to Python and this is my first post on this mailing list. I am confused as to why I am getting size differences in the following cases: >>> print struct.calcsize("I") 4 >>> print struct.calcsize("H") 2 >>> print struct.calcsize("HI") 8 >>> print struct.calcsize("

Re: Default/editable string to raw_input

2006-03-22 Thread Paraic Gallagher
Sybren Stuvel wrote: >My opinion: let the user edit the configuration file using his/her >favourite text editor. Someone configuring a test suite should >certainly be able to edit a text file. > >Sybren > > While I agree in principal to your opinion, the idea is that an absolute moron would be

Re: Using Dictionaries in Sets - dict objects are unhashable?

2006-03-22 Thread Gregory Piñero
Thanks guys. That was informative and helpful. I'm back on track now. -Greg On 21 Mar 2006 17:30:47 -0800, Ben Cartwright <[EMAIL PROTECTED]> wrote: > Gregory Piñero wrote: > > Hey guys, > > > > I don't understand why this isn't working for me. I'd like to be able > > to do this. Is there an

Re: Some info

2006-03-22 Thread Sybren Stuvel
Fulvio enlightened us with: > Alle 21:22, mercoledì 22 marzo 2006, Sybren Stuvel ha scritto: >> > disk names (CDroms or USB HDs). >> >> Depends on what names you want. > > It seems clear that was _disk_ names. What's a disk name? The filesystem label works as a disk name for ISO-9660 CDROMs, but e

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Mark Carter
Mark Carter wrote: > At the risk of being labelled a troll One thing I just discovered, and by which I mean *really* discovered ... is that Lisp is an interactive environment. I am working on trying to verify the contents of disks. I noticed that the input formats are slightly wrong, and neede

Re: struct size confusion:

2006-03-22 Thread Diez B. Roggisch
Michael Yanowitz wrote: >Why is it 8 bytes in the third case and why would it be only 6 bytes > in the last case if it is 8 in the previous? >From TFM: """ Native size and alignment are determined using the C compiler's sizeof expression. This is always combined with native byte order. Sta

Re: struct size confusion:

2006-03-22 Thread Kent Johnson
Michael Yanowitz wrote: > Hello: > >I am relatively new to Python and this is my first post on > this mailing list. > >I am confused as to why I am getting size differences in the following > cases: > > print struct.calcsize("I") > > 4 > print struct.calcsize("H") > > 2 > >>

Re: struct size confusion:

2006-03-22 Thread Fredrik Lundh
Michael Yanowitz wrote: >I am relatively new to Python and this is my first post on > this mailing list. > >I am confused as to why I am getting size differences in the following > cases: > > >>> print struct.calcsize("I") > 4 > >>> print struct.calcsize("H") > 2 > >>> print struct.calcsiz

Re: Default/editable string to raw_input

2006-03-22 Thread Sybren Stuvel
Paraic Gallagher enlightened us with: > While I agree in principal to your opinion, the idea is that an > absolute moron would be able to configure a testcell with smallest > amount of effort possible. Then explain to me why learning how to use your program to edit the file is easier than using an

string.upto() and string.from()

2006-03-22 Thread [EMAIL PROTECTED]
I often need to re-code for myself a small code snippet to define string.upto() and string.from(), which are used like : # canonical examples > "1234456789".upto("45") '1234' > "123456dd987".from('d') 'd987' # if not found, return whole string > "hello, world !".upto("#") "hello, world !" > u"hel

Re: nested for loops

2006-03-22 Thread John Salerno
Jesus Rivero - (Neurogeek) wrote: > It is, but range(2,2) doesn't do anything > > Jesus Rivero - Neurogeek > > > John Salerno wrote: > >> Can someone tell me why 'n' in this example isn't 2? >> > for n in range(2, 10): >> for x in range(2, n): >> print 'x =', x, 'n =', n >

Re: Per instance descriptors ?

2006-03-22 Thread Ziga Seilnacht
bruno at modulix wrote: > Hi > > I'm currently playing with some (possibly weird...) code, and I'd have a > use for per-instance descriptors, ie (dummy code): > Now the question: is there any obvious (or non-obvious) drawback with > this approach ? Staticmethods won't work anymore: >>> class

Re: multiple assignment

2006-03-22 Thread Anand
> You're right, that would not be so far off. > But then, the following should be also supported: > > *x, y = a # x, y = a[:-1], y = a[-1] > x, *y, z = a # x, y, z = a[0], a[1:-1], a[-1] > > Of course, there can be only one variable with an asterisk. > (But note that in the situation of a function

Refreshing Active Desktop Window

2006-03-22 Thread rodmc
I have written a small program which updates and HTML page in an active desktop (Internet Explorer) window. At present whenever it is refreshed it redraws the whole screen, I am using a very basic script from a Win32 example I found a while ago. Is there a way I can refresh the Window only and not

reading binary data written in C

2006-03-22 Thread Sheldon
Hi, I have a script that I want to use to read some binary lon and lat data that was written with a C program. My script looks like this:  lat = open(lat_file,'rb').read() lat = Numeric.fromstring(lat) print len(lat) print lat[0] Results: 1476225 -995001790 Or using the Float typecode: Results

Re: Default/editable string to raw_input

2006-03-22 Thread David Wahler
Paraic Gallagher wrote: > Hi, > > This is my first post to the list, I hope somebody can help me with this > problem. Apologies if it has been posted before but I have been internet > searching to no avail. > > What I am trying to do is provide a simple method for a user to change a > config file,

Re: string.upto() and string.from()

2006-03-22 Thread Tim Williams (gmail)
On 22 Mar 2006 06:41:32 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: I often need to re-code for myself a small code snippet to definestring.upto() and string.from(), which are used like : [snip] # if not found, return whole string> "hello, world !".upto("#") "hello, world !"> u"hello, wo

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread Arne Ludwig
> Can anyone suggest how I can get round this? I have attempted numerous > things, like making my recipient list = [''], but Exchange then tried > to send the mail to "[EMAIL PROTECTED]" . rfc822: Note that the "Bcc" field may be empty, while the "To" field rfc822: is required to have a

Re: string.upto() and string.from()

2006-03-22 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > I often need to re-code for myself a small code snippet to define > string.upto() and string.from(), which are used like : > > Nothing very complicated to make with find and rfind, but wouldn't this > be handy to have it ready in the common string method ? Something

Re: string.upto() and string.from()

2006-03-22 Thread Tim Williams (gmail)
On 22/03/06, Tim Williams (gmail) <[EMAIL PROTECTED]> wrote: > if  u"h" in u"hello, world !" and u"hello, world !".from("h"): >  return " u"hello, world !" >else:   # not really required, used for demonstration only >  return :) OK,  python allows me to code faster than I can think ( n

Re: string.upto() and string.from()

2006-03-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I often need to re-code for myself a small code snippet to define > string.upto() and string.from(), which are used like : > > # canonical examples > > "1234456789".upto("45") > '1234' > > "123456dd987".from('d') > 'd987' > > # if not found, return whole string > > "hell

Re: doctest, unittest, or if __name__='__main__'

2006-03-22 Thread john_sips_tea
> so you think that a "why all this creativity when you could just > standardize on something ported from java, and throw away every- > thing else" post is friendly ? really ? Sorry for the sloppy writing. Thanks for clarifying. I wrote: > If unittest is the standard way to write test code, why

RE: struct size confusion:

2006-03-22 Thread Michael Yanowitz
Thanks for your and everyone else's feedback. I got it to work now by prefixing the PACK_FORMAT with "!". I previously thought I could only use the "!' with the unpack. I still don't fully understand the byte allignment stuff (I am sure I will get it eventually), but I am content that it is workin

Windows getting local ip address

2006-03-22 Thread SolaFide
On Linux, it is a simple matter to get the local ip address with system.os("ifconfig >> /tmp/ip"); ip=open("/tmp/ip").readlines(), etc. How can I do this with Windows? -- http://mail.python.org/mailman/listinfo/python-list

Re: Per instance descriptors ?

2006-03-22 Thread bruno at modulix
Ziga Seilnacht wrote: > bruno at modulix wrote: > >>Hi >> >>I'm currently playing with some (possibly weird...) code, and I'd have a >>use for per-instance descriptors, ie (dummy code): > > > > >>Now the question: is there any obvious (or non-obvious) drawback with >>this approach ? > > > St

Re: Default/editable string to raw_input

2006-03-22 Thread Paraic Gallagher
David Wahler wrote: >With the disclaimer that, as others have said, this may not be the best >user-interface choice: > > import readline > readline.set_startup_hook(lambda: readline.insert_text(old_value)) > try: >new_value = raw_input() > finally: >readline.set_startup_hook(None) > >N

Re: reading binary data written in C

2006-03-22 Thread Grant Edwards
On 2006-03-22, Sheldon <[EMAIL PROTECTED]> wrote: > I have a script that I want to use to read some binary lon and lat data > that was written with a C program. http://www.python.org/doc/current/lib/module-struct.html -- Grant Edwards grante Yow! UH-OH!! We're out

Re: Windows getting local ip address

2006-03-22 Thread Fredrik Lundh
"SolaFide" wrote: > On Linux, it is a simple matter to get the local ip address with > system.os("ifconfig >> /tmp/ip"); ip=open("/tmp/ip").readlines(), etc. ip = os.popen("ifconfig").readlines() is a bit more convenient. > How can I do this with Windows? the command is called "ipconfig" i

Re: Windows getting local ip address

2006-03-22 Thread utabintarbo
You can do essentially the same thing substituting "ipconfig" for ifconfig. Though I am sure there are better ways -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows getting local ip address

2006-03-22 Thread Arne Ludwig
The second solution can give really weird results though, e.g. on my Linux system I get: >>> gethostbyaddr(gethostname()) ('linux.site', ['linux'], ['127.0.0.2']) A more flexible but potentially unportable way would be: >>> import socket >>> import fcntl >>> import struct >>> >>> def get_ip_addr

Re: string.upto() and string.from()

2006-03-22 Thread Kent Johnson
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > >>I often need to re-code for myself a small code snippet to define >>string.upto() and string.from(), which are used like : FWIW this is pretty easy to do with str.split() and rsplit(): >> >># canonical examples >> >>>"1234456789".upto("45") >

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread EdWhyatt
So it's a restriction of Python? What I am trying to simulate here is the sending of mail to addresses solely in the CC and/or BCC fields - both of which are possible through Outlook. -- http://mail.python.org/mailman/listinfo/python-list

import random module

2006-03-22 Thread DataSmash
Hi, When I import the random module at the python interpreter, it works fine: >>> import random >>> x = random.randint(1,55) >>> print x 14 >>> BUT, when I put the same code in a python script: * random.py: import random x = random.randint(1,55) print x and run it at the command line, I get: Tr

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Alexander Schmolck
Mark Carter <[EMAIL PROTECTED]> writes: > A programmers mindset is usually geared towards "writing applications". What > I'm currently doing in Lisp is building up functions as I need them. Using > emacs, I can just C-x C-e to make my functions "live", and when it's time to > stop for the day, save

Re: import random module

2006-03-22 Thread Diez B. Roggisch
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: import random x = random.randint(1,55) print x > 14 > > BUT, when I put the same code in a python script: > * random.py: ^^ There is your problem: you named your module "

Re: import random module

2006-03-22 Thread Benjamin Niemann
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: import random x = random.randint(1,55) print x > 14 > > BUT, when I put the same code in a python script: > * random.py: > > import random > > x = random.randint(1,55) > prin

Re: import random module

2006-03-22 Thread Daniel Dittmar
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: import random x = random.randint(1,55) print x > 14 > > BUT, when I put the same code in a python script: > * random.py: > > import random > > x = random.randint(1,55) > print x >

Re: import random module

2006-03-22 Thread Jorge Godoy
"DataSmash" <[EMAIL PROTECTED]> writes: > Hi, > When I import the random module at the python interpreter, it works > fine: import random x = random.randint(1,55) print x > 14 > > BUT, when I put the same code in a python script: > * random.py: > > import random > > x = random.

Re: import random module

2006-03-22 Thread Gerard Flanagan
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: > >>> import random > >>> x = random.randint(1,55) > >>> print x > 14 > >>> > > BUT, when I put the same code in a python script: > * random.py: > > import random > > x = random.randint(1,55) > pr

Re: import random module

2006-03-22 Thread Michael Tobis
1) remove the file random.pyc in your working directory 2) rename the file random.py to something else and run it. The import mechanism is looking for random.pyc or random.py, but you have already named your file that! Your current directory is above your library directory in python's search path

Re: string.upto() and string.from()

2006-03-22 Thread [EMAIL PROTECTED]
Sure, you're right I forgot about rsplit ! I guess the negative indexes & al could be done with sep.join(xyz.split(sep)[:index]) Thanks ! -- http://mail.python.org/mailman/listinfo/python-list

Objective Cairo

2006-03-22 Thread federico . pelloni
As pycairo is one of the less pythonish things I ever saw, it went into my mind to create some sort of objective wrapper over its python api making graphic manipulation much more coherent to the python way. As of the moment, I can: - create (and reorder) multiple layers (this is not present in th

Re: import random module

2006-03-22 Thread Richard Brodie
"Benjamin Niemann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Don't name your script 'random.py' (or any other name from the stdlib). > 'import random' will import the script itself (not the random module from > the stdlib), which is not what you want. I discovered long, long

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread Jeffrey Froman
EdWhyatt wrote: > I would like to have the ability to send a mail > message with no-one email address in the To field. The to_addrs parameter is for the SMTP "RCPT TO", which must contain at least one address. It has nothing to do with the To: header of the email. You can *also* add the recipien

Need help with restricting number of new objects a user script can create

2006-03-22 Thread vj
I'm building a large infrastructure with about 30 servers (all running linux). I allow my end users to write scripts which then get broken down in smaller parts and run across the 30 servers. The results from each individual run are combined and presented back to the user. I'm currently using pyli

Re: import random module

2006-03-22 Thread DataSmash
Much Thanks! I deleted the random.pyc and renamed the script and everything is good! R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: import random module

2006-03-22 Thread DataSmash
Much Thanks! I deleted the random.pyc and renamed the script and everything is good! R.D. -- http://mail.python.org/mailman/listinfo/python-list

SciPy problem

2006-03-22 Thread Tommy Grav
I am new to Python and just downloaded ActivePython 2.4.2.10 on my Mac PPC with OS X 10.4.I added the numpy package (0.9.6-py2.4) and it imports fine. But when I try to import scipy (0.4.8-py2.4)I get an error:>>> import scipyTraceback (most recent call last):  File "", line 1, in ?  File "/Library

Re: import random module

2006-03-22 Thread Tomas Brabenec
You must rename Your script. Your script doesn't same name as calling module. Tomas Brabenec http://brabenec.net DataSmash napsal(a): > Hi, > When I import the random module at the python interpreter, it works > fine: > import random x = random.randint(1,55) print x

Re: Need help with restricting number of new objects a user script can create

2006-03-22 Thread Sybren Stuvel
vj enlightened us with: > how do I restrict the user from (inadvertently or maliciously) > creating a large number of objects which will bring down the entire > 100 nodes. Use ulimit to give them a limited amount of CPU time, memory etc. The kernel will then kill runaway processes. Sybren -- The

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Dirk Thierbach
[Had to drop alt.comp.lang.haskell, otherwise my newsserver doesn't accept it] Dinko Tenev <[EMAIL PROTECTED]> wrote: > OK, here's a case that will make your program run in exponential time: > S = { a, b }, W = { *a*b, *b*a } -- on my machine, it starts getting > ugly as soon as n is 15 or so. No

Wrap a dictionary in a class?

2006-03-22 Thread Joseph Turian
In another thread, it was recommended that I wrap a dictionary in a class. How do I do so? Joseph that thread: http://groups.google.com/group/comp.lang.python/browse_frm/thread/9a0fbdca450469a1/b18455aa8dbceb8a?q=turian&rnum=1#b18455aa8dbceb8a -- http://mail.python.org/mailman/listinfo/pytho

creating custom options for custom widgets?

2006-03-22 Thread Alexandre Guimond
Hi all. I'm creating a new widget class using Tkinter (class inherited form Tkinter.Frame). This class creates a bunch of other widgets inside it that can be "gridded" either horizontally or vertically. I would like to provide the user of the class an option to change this layout on the fly, using

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread EdWhyatt
Ok, totally unrelated, and on that subject, I will make sure I always have a recipient in the To: field. - hey it works if I do that anyway! But are you serious about that RFC Compliant thing? Can anyone shed anymore light on this? I cannot believe that (regardless of our opinions of them) Microso

Re: import random module

2006-03-22 Thread Michael Tobis
Wow. Six simultaneous responses! Python rocks! Anyway, I actually tried it, and persisted through the secondary confusion about the lurking .pyc file, so even though I'm in sixth place I get points for completeness... mt -- http://mail.python.org/mailman/listinfo/python-list

Newbie: Print question

2006-03-22 Thread Tommy Grav
Being new to Python I am getting a result I do not understand.I have a code that reads in a set of lines from a file, slits upthe lines and puts information into a list of class objects.    obslist = mpc.Read_Observations(options.in_fname) ;        for testobs in obslist:        print testobs.print

Re: Python vs. Java gzip performance

2006-03-22 Thread Martin v. Löwis
Felipe Almeida Lessa wrote: > def readlines(self, sizehint=None): > if sizehint is None: > return self.read().splitlines(True) > # ... > > Is it okay? Or is there any embedded problem I couldn't see? It's dangerous, if the file is really large - it might exhaust your mem

Re: Newbie: Print question

2006-03-22 Thread Fredrik Lundh
Tommy Grav wrote: > for testobs in obslist: > print testobs.printmpc() print. > def printmpc(self): > if self.mag!="": > print "%14s %12.5f %5.2f %6.2f %8.3f %3i" and print. > I don't understand where these None's are coming from. for each testobs

Re: string.upto() and string.from()

2006-03-22 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Sure, you're right I forgot about rsplit ! > I guess the negative indexes & al could be done with > > sep.join(xyz.split(sep)[:index]) For index=-1 use xyz.rsplit(sep, 1)[0] Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrap a dictionary in a class?

2006-03-22 Thread Daniel Nogradi
> In another thread, it was recommended that I wrap a dictionary in a > class. > How do I do so? I guess this is what you want: http://vsbabu.org/mt/archives/2003/02/13/joy_of_python_classes_and_dictionaries.html HTH, Daniel -- http://mail.python.org/mailman/listinfo/python-list

Trouble with generator as method

2006-03-22 Thread Peter Cole
I'm having difficulty understanding why this doesn't work: import sys, new, inspect class T: def foo(self): yield 1 yield 2 yield 3 t = T() ic = t.__class__ for key in ic.__dict__.keys(): if inspect.isfunction(ic.__dict__[key]): im = new.instancemetho

Re: Server.sendmail with no "to_addrs" parameter.

2006-03-22 Thread Tim Williams (gmail)
On 22 Mar 2006 08:31:16 -0800, EdWhyatt <[EMAIL PROTECTED]> wrote: So it's a restriction of Python?What I am trying to simulate here is the sending of mail to addressessolely in the CC and/or BCC fields - both of which are possible throughOutlook.-- http://mail.python.org/mailman/listinfo/python-li

  1   2   3   >