Re: Problem using pbzip2 with bz2.BZ2File().read()

2010-06-21 Thread Chris Rebert
On Mon, Jun 21, 2010 at 5:32 PM, Ameet Nanda wrote: > When I compress a file with bzip2 from command line and read it with > uncomp_data = bz2.BZ2File("fname").read() , it reads the whole file into > uncomp_data. > > However when I compress the file with pbzip2 from command line and read it > in a

Re: What is the difference between 'type' and 'class'?

2010-06-21 Thread Steven D'Aprano
On Mon, 21 Jun 2010 15:43:01 -0700, Stephen Hansen wrote: > many types are fundamentally immutable(i.e., ints, strings), and its > awful hard to make an immutable class. It's really simple if you can inherit from an existing immutable class. class K(tuple): pass Of course, that lets you ad

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread alex23
DivX wrote: > Another thing is that when you have assembler now you can write some > small C compiler so that you don’t have to write assembly language. That has to be the most paradoxical argument I've ever heard: "when you use assembler you have the ability to not use assembler" :) -- http://

Re: What is the difference between 'type' and 'class'?

2010-06-21 Thread Terry Reedy
On 6/21/2010 6:11 PM, Peng Yu wrote: pydoc xrange says: Help on class xrange in module __builtin__: class xrange(object) python_2.6.5_library.pdf says: Objects of type xrange are similar to buffers Are type and class synonyms? It seems that they are at least according to some webpages that I

[ANN] AutoRecalcDict 0.1.1 released

2010-06-21 Thread Steven W. Orr
AutoRecalcDict is a subclass of dict that allows programmers to create user defined dependencies and functions on target keys. You can find it at http://pypi.python.org/pypi/AutoRecalcDict/0.1.1 I recently was designing tests for radio frequency analysis (about which, I know nothing). All of the

Re: setup server from scratch (with or without apache?)

2010-06-21 Thread News123
Hi Kruptein, Kruptein wrote: > I think that apache and mod_python are good enough, but I'm not an > expert. > > but I think that the security aspect for a large part depends on how > secure your code is. > > You can have a very secure server setting, but somewhere a bug in your > code that makes

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 5:13 pm, Stephen Hansen wrote: > On 6/21/10 4:26 PM, davidgp wrote: > > > > > > > ah, i see :P > > float("45.34") or whatever does work fine, but the problem is that i'm > > reading it from a text file. so somehow it is not a real string or > > whatever.. > > here's a part of the code:

Problem using pbzip2 with bz2.BZ2File().read()

2010-06-21 Thread Ameet Nanda
When I compress a file with bzip2 from command line and read it with *uncomp_data = bz2.BZ2File("fname").read()* , it reads the whole file into uncomp_data. However when I compress the file with pbzip2 from command line and read it in a similar way* it just reads the block size of data* used for c

Re: setup server from scratch (with or without apache?)

2010-06-21 Thread News123
News123 wrote: > Hi, > > > So far I never really had to ask this question and this is also, why I > am stil a little shaky on this topic: > > So far the typical LAMP server existed already and contained already a > lot of existing PHP web applications, which I couldn't remove. > Therefore I just us

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:26 PM, davidgp wrote: > ah, i see :P > float("45.34") or whatever does work fine, but the problem is that i'm > reading it from a text file. so somehow it is not a real string or > whatever.. > here's a part of the code: > f = open ('/home/david/out.txt', 'r') > > for line in f: > if

Re: float from numbers in text file

2010-06-21 Thread GMail Felipe
On 21/06/2010, at 20:26, davidgp wrote: On Jun 21, 4:18 pm, Stephen Hansen wrote: On 6/21/10 4:03 PM, davidgp wrote: sorry :) Okay, I should be more specific: include full tracebacks and some real copied and pasted code :) Don't throw away nice debugging information Python gave you,

Re: tkInter Listbox question

2010-06-21 Thread Anthony Papillion
Thank you, RantingRick and EB303. Much appreciated and it looks like it works fine now. Still learning but I am amazed every single day how simple Python is! Thanks Again, Anthony Papillion -- http://mail.python.org/mailman/listinfo/python-list

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 4:18 pm, Stephen Hansen wrote: > On 6/21/10 4:03 PM, davidgp wrote: > > > > > sorry :) > > Okay, I should be more specific: include full tracebacks and some real > copied and pasted code :) Don't throw away nice debugging information > Python gave you, feed it to us. > > > invalid liter

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 4:03 PM, davidgp wrote: > > sorry :) Okay, I should be more specific: include full tracebacks and some real copied and pasted code :) Don't throw away nice debugging information Python gave you, feed it to us. > invalid literal for long() with base 10: '51.9449702' > this is the error

Re: float from numbers in text file

2010-06-21 Thread davidgp
On Jun 21, 4:00 pm, Stephen Hansen wrote: > On 6/21/10 3:54 PM, davidgp wrote: > > > i basically tried this: > > lat =0.0 > > for line in f: > >   lat = float(line) > > > but this gives an error.. does anyone know what i should to do? > > thanks, > > "An error"? > > Python 2.6.1 (r261:67515, Feb 1

Re: float from numbers in text file

2010-06-21 Thread Stephen Hansen
On 6/21/10 3:54 PM, davidgp wrote: > i basically tried this: > lat =0.0 > for line in f: > lat = float(line) > > but this gives an error.. does anyone know what i should to do? > thanks, "An error"? Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin

float from numbers in text file

2010-06-21 Thread davidgp
hello, i have a text file that contains gps coordinates that i want to load into my mysql database the file is basically in this format: 52.2375412 5.1802704 i basically tried this: lat =0.0 for line in f: lat = float(line) but this gives an error.. does anyone know what i should to do? thanks,

Re: What is the difference between 'type' and 'class'?

2010-06-21 Thread Stephen Hansen
On 6/21/10 3:11 PM, Peng Yu wrote: > Are type and class synonyms? It seems that they are at least according > to some webpages that I read. But I'm not completely sure. Could you > let me know in case my impress is wrong? Once upon a time, a type was something that was only built-in, provided by P

Re: What is the difference between 'type' and 'class'?

2010-06-21 Thread Thomas Jollans
On 06/22/2010 12:11 AM, Peng Yu wrote: > pydoc xrange says: > > Help on class xrange in module __builtin__: > > class xrange(object) > > python_2.6.5_library.pdf says: > > Objects of type xrange are similar to buffers > > Are type and class synonyms? It seems that they are at least according >

[ANN] python-signalfd 0.1 released

2010-06-21 Thread exarkun
Hello all, I'm happy to announce the initial release of python-signalfd. This simple package wraps the sigprocmask(2) and signalfd(2) calls, useful for interacting with POSIX signals in slightly more advanced ways than can be done with the built-in signal module. You can find the package on

What is the difference between 'type' and 'class'?

2010-06-21 Thread Peng Yu
pydoc xrange says: Help on class xrange in module __builtin__: class xrange(object) python_2.6.5_library.pdf says: Objects of type xrange are similar to buffers Are type and class synonyms? It seems that they are at least according to some webpages that I read. But I'm not completely sure. Cou

Re: What module to parse/generate ical files?

2010-06-21 Thread Michael Crute
On Mon, Jun 21, 2010 at 1:50 PM, Grant Edwards wrote: > What module is recommended for parsing/generating ical files? > > However, I'm not sure it's being maintained.  Despite the claim on the > above page that the current version is 2.1, The latest version I can > find is v1.2 from 2006. I've ha

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Rhodri James
On Mon, 21 Jun 2010 04:34:40 +0100, Steven D'Aprano wrote: On Sun, 20 Jun 2010 22:45:14 +0100, Rhodri James wrote: No. Modern C compilers often produce very good machine code, but the best hand-written assembly code will be better. I can usually write *very* marginally better code than GC

Re: process cannot access the file because it is being used by other process

2010-06-21 Thread Thomas Jollans
On 06/21/2010 12:18 PM, shanti bhushan wrote: > [snip] > > i used below code > > import subprocess > import time > def invoke_server1(): > proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C "D: > \372\pythonweb\mongoose-2.8.exe -root D:\New1\"') > > > invoke_server1() > > > time.sle

Re: process cannot access the file because it is being used by other process

2010-06-21 Thread Chris Rebert
On Mon, Jun 21, 2010 at 6:44 AM, Felipe Vinturini wrote: > Your problem seems to be with stdout redirect to the same file: > ">YourOutput1.txt". Windows is not like Unix like systems! > You can try, instead of redirecting to the same file, redirect each to a > separate file and use the following

Re: Help with suds: HTTP Error 401

2010-06-21 Thread plainsane
On Jun 19, 12:16 pm, Sean DiZazzo wrote: > On Jun 11, 5:27 am, Eric von Horst wrote: > > > I have small program that tries to open a wsdl. When I execute the > > program I am getting 'suds.transport.TransportError: HTTP Error 401: > > Unauthorized' > > Hey Eric, > > Im a suds noob as well.  I fou

Re: __slot__: what is it good for?

2010-06-21 Thread Stephen Hansen
On 6/21/10 11:06 AM, Terry Reedy wrote: > On 6/21/2010 11:24 AM, Stephen Hansen wrote: >> On 6/21/10 8:08 AM, Stephen Hansen wrote: >>> If you don't want a class to have attributes added at runtime, the > >> The Pythonic way to achieve that is to... simply NOT add attributes at >> runtime. >> >> I

Re: Decode II (more complex)

2010-06-21 Thread John Bokma
Thomas Lehmann writes: >> Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess >> your problem is solved. >> >> How do you email the notifications? >> > > I was copying partly the logic from > http://code.activestate.com/recipes/473810 > Changing to buffer.decode("utf-8", '

Re: Generator (re-)definition within a loop

2010-06-21 Thread Terry Reedy
On 6/21/2010 3:29 AM, Pierre Reinbold wrote: On 06/18/2010 11:48 PM, Terry Reedy wrote: Let's apply Reedy's Rule: when you have trouble understanding a function expression, replace it with the (near) equivalent def statement. (Among other advantages, one can insert print calls!) Genexps, lik

Re: __slot__: what is it good for?

2010-06-21 Thread Terry Reedy
On 6/21/2010 11:24 AM, Stephen Hansen wrote: On 6/21/10 8:08 AM, Stephen Hansen wrote: If you don't want a class to have attributes added at runtime, the The Pythonic way to achieve that is to... simply NOT add attributes at runtime. I.e., choose to follow the rule you've decided on. Or ad

Re: deduping

2010-06-21 Thread Paul Rubin
dirknbr writes: > done_={} > for line in done: > done_[line.strip()]=0 > ... Maybe you mean: done_ = set(line.strip() for line in done) outf_ = set(line.split(',')[1] for line in outf) universe = done_ & outf # this finds the set intersection -- http://mail.python.org/mailman/

Re: Generator (re-)definition within a loop

2010-06-21 Thread Thomas Jollans
On 06/21/2010 09:29 AM, Pierre Reinbold wrote: > [snip] > > Another try to avoid infinite recursion: > > def badgen_product2(*args, **kwds): > pools = map(tuple, args) > result = [[]] > for pool in pools: > def augments(): > for x in result: This line is executed w

Re: Where is the help function defined?

2010-06-21 Thread Terry Reedy
On 6/21/2010 1:17 PM, Peng Yu wrote: help(help) gives me the following explanation. ## Help on _Helper in module site object: class _Helper(__builtin__.object) | Define the built-in 'help'. See 'built-in'? | This is a wrapper around pydoc.help (with a twist). | |

Re: Where is the help function defined?

2010-06-21 Thread Emile van Sebille
On 6/21/2010 10:17 AM Peng Yu said... help(help) gives me the following explanation. I then looked at pydoc site. But I don't see an entry on help(). How to figure out where help() (or a function in general) is defined? ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on Python 2.4.1

What module to parse/generate ical files?

2010-06-21 Thread Grant Edwards
What module is recommended for parsing/generating ical files? Specifically, I'd like to parse invitations generated by MS Outlook and generate accept/decline responses. I've tinkered with iCalendar 1.2, and have had some success after manualling munging/filtering the data for some fields: http

ANNOUNCING Tahoe, the Least-Authority File System, v1.7.0

2010-06-21 Thread Zooko O'Whielacronx
Dear people of python-list: We just released Tahoe-LAFS v1.7, the secure distributed filesystem written entirely [*] in Python. The major new feature is an SFTP server. This means that (with enough installing software and tinkering with your operating system configuration) you can have a normal-l

Re: Where is the help function defined?

2010-06-21 Thread Thomas Jollans
On 06/21/2010 07:17 PM, Peng Yu wrote: > help(help) gives me the following explanation. > > [snip] > > I then looked at pydoc site. But I don't see an entry on help(). How > to figure out where help() (or a function in general) is defined? >>> type(dir) >>> type(help) >>> help is not a funct

Re: Where is the help function defined?

2010-06-21 Thread Stephen Hansen
On 6/21/10 10:17 AM, Peng Yu wrote: > Help on _Helper in module site object: It says so right here. > I then looked at pydoc site. But I don't see an entry on help(). How > to figure out where help() (or a function in general) is defined? Generally: Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Stephen Hansen
On 6/21/10 10:12 AM, MRAB wrote: > A human can write better assembly code than a compiler, but would take a > much longer, and usually for not much gain, so it's usually a waste of > time (premature optimisation, and all that). When you get to the point where you're considering writing something i

Where is the help function defined?

2010-06-21 Thread Peng Yu
help(help) gives me the following explanation. ## Help on _Helper in module site object: class _Helper(__builtin__.object) | Define the built-in 'help'. | This is a wrapper around pydoc.help (with a twist). | | Methods defined here: | | __call__(self, *args, **kwds) |

[RELEASED] Python 2.7 release candidate 2

2010-06-21 Thread Benjamin Peterson
On behalf of the Python development team, I'm tickled pink to announce the second release candidate of Python 2.7. Python 2.7 is scheduled (by Guido and Python-dev) to be the last major version in the 2.x series. However, 2.7 will have an extended period of bugfix maintenance. 2.7 includes many f

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread MRAB
David Cournapeau wrote: On Mon, Jun 21, 2010 at 12:34 PM, Steven D'Aprano wrote: On Sun, 20 Jun 2010 22:45:14 +0100, Rhodri James wrote: Mixing Python and assembler is a bizarre thing to want to do in general, but... On Sun, 20 Jun 2010 01:52:15 +0100, Steven D'Aprano wrote: (3) Modern C

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread David Cournapeau
On Mon, Jun 21, 2010 at 12:34 PM, Steven D'Aprano wrote: > On Sun, 20 Jun 2010 22:45:14 +0100, Rhodri James wrote: > >> Mixing Python and assembler is a bizarre thing to want to do in general, >> but... >> >> On Sun, 20 Jun 2010 01:52:15 +0100, Steven D'Aprano >> wrote: >> >>> (3) Modern C compil

Re: tkInter Listbox question

2010-06-21 Thread rantingrick
On Jun 21, 12:36 am, Anthony Papillion wrote: > So I'm trying to add a Listbox to my window. I want it to be the width > of my window and the height of my window.  I'm using the following > code ('root' is my toplevel window): > > gsItems = Listbox(root, width=root.winfo_width(), > height=root.win

Re: Decode II (more complex)

2010-06-21 Thread Thomas Lehmann
> Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess > your problem is solved. > > How do you email the notifications? > I was copying partly the logic from http://code.activestate.com/recipes/473810 Changing to buffer.decode("utf-8", 'replace') where I'm reading the file a

Re: __slot__: what is it good for?

2010-06-21 Thread Stephen Hansen
On 6/21/10 8:08 AM, Stephen Hansen wrote: > If you don't want a class to have attributes added at runtime, the > Pythonic way to achieve that is to... simply add attributes at runtime. Errr. The Pythonic way to achieve that is to... simply NOT add attributes at runtime. I.e., choose to follow th

Re: __slot__: what is it good for?

2010-06-21 Thread Peter Otten
Alexander Eisenhuth wrote: > - what is the reason, that __slots__ are introduced in python? When you have "many" instances of a class with a fixed set of attributes __slots__ can save you some memory because it avoids the overhead for the instance __dict__. Note that "many" means millions rathe

Re: __slot__: what is it good for?

2010-06-21 Thread Stephen Hansen
On 6/21/10 7:27 AM, Alexander Eisenhuth wrote: > Hello out there, > > - what is the reason, that __slots__ are introduced in python? > > - I want to use slots to define a class where no attributes are added at > runtime. Is that a good idea to use slots for that? In short, its best to use __slot

Re: If Not CGI...

2010-06-21 Thread Victor Subervi
On Mon, Jun 21, 2010 at 9:03 AM, Tim Chase wrote: > On 06/21/2010 07:40 AM, Victor Subervi wrote: > >> I would like to explore rewriting the shopping cart in Django. >> The reality of the matter may make it difficult. Working >> literally from the time I awake to when I go to sleep and not >> havi

Re: Decode II (more complex)

2010-06-21 Thread John Bokma
Thomas Lehmann writes: > Hi all, > > I have written a small python xmlrpc server which checks logfiles of a > build > sending notifications to the responsible teams. On a machine I'm > forced to > a problem with one logfile with special characters inside generated by > a > gnu compiler. > > Using

Re: __slot__: what is it good for?

2010-06-21 Thread James Mills
On Tue, Jun 22, 2010 at 12:27 AM, Alexander Eisenhuth wrote: > Hello out there, > > - what is the reason, that __slots__ are introduced in python? > > - I want to use slots to define a class where no attributes are added at > runtime. Is that a good idea to use slots for that? Here is the relevan

__slot__: what is it good for?

2010-06-21 Thread Alexander Eisenhuth
Hello out there, - what is the reason, that __slots__ are introduced in python? - I want to use slots to define a class where no attributes are added at runtime. Is that a good idea to use slots for that? Regards Alexander -- http://mail.python.org/mailman/listinfo/python-list

Re: OT! Python vs... Objective-C!

2010-06-21 Thread Stephen Hansen
On 6/21/10 6:47 AM, Grant Edwards wrote: > On 2010-06-21, Stephen Hansen wrote: > > [...] > >> I'm just learning Objective-C on my spare time, and am having these >> entirely disturbing feelings of familiarity, where strange swirling >> thoughts enter my head that sound oddly like, "This feels s

Re: OT! Python vs... Objective-C!

2010-06-21 Thread Grant Edwards
On 2010-06-21, Stephen Hansen wrote: [...] > I'm just learning Objective-C on my spare time, and am having these > entirely disturbing feelings of familiarity, where strange swirling > thoughts enter my head that sound oddly like, "This feels sorta > Pythony, how oddly pleasant." With, of course

Re: process cannot access the file because it is being used by other process

2010-06-21 Thread Felipe Vinturini
On Mon, Jun 21, 2010 at 7:18 AM, shanti bhushan wrote: > On Jun 21, 2:15 pm, Tim Golden wrote: > > On 21/06/2010 09:23, shanti bhushan wrote: > > > > > i am using below code ,it works fine on ordinary python 26 ,but when i > > > use this script in my python testing tool it gives me message "proce

Re: If Not CGI...

2010-06-21 Thread Tim Chase
On 06/21/2010 07:40 AM, Victor Subervi wrote: I would like to explore rewriting the shopping cart in Django. The reality of the matter may make it difficult. Working literally from the time I awake to when I go to sleep and not having enough hours to complete everything I set for myself makes it

Re: deduping

2010-06-21 Thread Peter Otten
dirknbr wrote: > Hi > > I have 2 files (done and outf), and I want to chose unique elements > from the 2nd column in outf which are not in done. This code works but > is not efficient, can you think of a quicker way? The a=1 is just a > redundant task obviously, I put it this way around because I

Re: deduping

2010-06-21 Thread Dave Angel
dirknbr wrote: Hi I have 2 files (done and outf), and I want to chose unique elements from the 2nd column in outf which are not in done. This code works but is not efficient, can you think of a quicker way? The a=1 is just a redundant task obviously, I put it this way around because I think 'in'

Re: deduping

2010-06-21 Thread python
Use a set instead of a dictionary for done keys? Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Dave Angel
Steven D'Aprano wrote: On Mon, 21 Jun 2010 03:00:12 -0400, Dave Angel wrote: But the OP said of his friend: "He dynamically generates mashine code and call that from python." I took that to mean he dynamically generated machine code, not that he hired some human to do it. Well, I

Re: deduping

2010-06-21 Thread Thomas Lehmann
> universe={} > for line in outf: >     if line.split(',')[1].strip() in universe.keys(): >         a=1 >     else: >         if line.split(',')[1].strip() in done_.keys(): >             a=1 >         else: >             universe[line.split(',')[1].strip()]=0 > I can not say too much because I don

Decode II (more complex)

2010-06-21 Thread Thomas Lehmann
Hi all, I have written a small python xmlrpc server which checks logfiles of a build sending notifications to the responsible teams. On a machine I'm forced to a problem with one logfile with special characters inside generated by a gnu compiler. Using cheetah for generating the HTML mail I get a

Re: If Not CGI...

2010-06-21 Thread Victor Subervi
I really can't begin to thank you guys enough. Great information, goes without saying. A lot to consider. I would like to explore rewriting the shopping cart in Django. The reality of the matter may make it difficult. Working literally from the time I awake to when I go to sleep and not having enou

deduping

2010-06-21 Thread dirknbr
Hi I have 2 files (done and outf), and I want to chose unique elements from the 2nd column in outf which are not in done. This code works but is not efficient, can you think of a quicker way? The a=1 is just a redundant task obviously, I put it this way around because I think 'in' is quicker than

Re: start and kill process by command promt

2010-06-21 Thread Giampaolo Rodolà
There's no need to use taskill.exe; keep a reference of the subprocess.Popen() object around and use its kill() method instead. --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil 2010/6/21 shanti bhushan : > On Jun 21, 10:41 am, shanti bhushan wrote: >> Hi, >> I w

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread DivX
On 20 lip, 12:57, DivX wrote: > On 20 lip, 12:46, Steven D'Aprano > > > > > cybersource.com.au> wrote: > > On Sun, 20 Jun 2010 03:19:48 -0700, DivX wrote: > > > On 20 lip, 02:52, Steven D'Aprano > > cybersource.com.au> wrote: > > [...] > > >> I think that mixing assembly and python is a gimmick

Re: constructing an object from another instance of the same class

2010-06-21 Thread Carl Banks
On Jun 18, 3:55 pm, Christoph Groth wrote: > Bruno Desthuilliers writes: > > Anyway: the simplest solution here is to replace the call to your Base > > class with a call to a factory function. I'd probably go for something > > like (Q&D untested code and other usual warnings) : > > > (...) > > Ye

Re: setup server from scratch (with or without apache?)

2010-06-21 Thread Christian Heimes
> I will only have one IP address and only port 443. > > 1.) What alternatives would exist compared to apache / mod_python You can use a combination of mod_proxy and mod_rewrite to set up a forwarding proxy in your Apache server. Let Apache deal with SSL, virtual hosting etc. Then bind your appli

Re: process cannot access the file because it is being used by other process

2010-06-21 Thread shanti bhushan
On Jun 21, 2:15 pm, Tim Golden wrote: > On 21/06/2010 09:23, shanti bhushan wrote: > > > i am using below code ,it works fine on ordinary python 26 ,but when i > > use this script in my python testing tool it gives me message "process > > cannot access the file because it is being used by other pr

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Steven D'Aprano
On Mon, 21 Jun 2010 03:00:12 -0400, Dave Angel wrote: > But the OP said of his friend: > > "He dynamically generates mashine code and call that from python." > > I took that to mean he dynamically generated machine code, not that he > hired some human to do it. Well, I suppose if his friend i

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
On Jun 20, 10:58 pm, Cameron Simpson wrote: > On 20Jun2010 12:44, Stefan Behnel wrote: > | southof40, 20.06.2010 12:19: > | >I have list of of N Vehicle objects - the only possible vehicles are > | >cars, bikes, trucks. > | > > | >I want to select an object from the list with a probability of : c

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
On Jun 20, 11:27 pm, Mel wrote: > southof40 wrote: > > I have list of of N Vehicle objects - the only possible vehicles are > > cars, bikes, trucks. > > > I want to select an object from the list with a probability of : cars > > 0.7, bikes 0.3, trucks 0.1. > > > I've currently implemented this by

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
On Jun 20, 10:55 pm, Rob Williscroft wrote: > southof40 wrote in news:da3cc892-b6dd-4b37-a6e6- > b606ef967...@t26g2000prt.googlegroups.com in gmane.comp.python.general: > > > I have list of of N Vehicle objects - the only possible vehicles are > > cars, bikes, trucks. > > > I want to select an obj

Re: setup server from scratch (with or without apache?)

2010-06-21 Thread Bruno Desthuilliers
News123 a écrit : Hi, So far I never really had to ask this question and this is also, why I am stil a little shaky on this topic: So far the typical LAMP server existed already and contained already a lot of existing PHP web applications, which I couldn't remove. Therefore I just used mod_pyt

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
On Jun 20, 10:53 pm, Steven D'Aprano wrote: > On Sun, 20 Jun 2010 03:19:55 -0700, southof40 wrote: > > I have list of of N Vehicle objects - the only possible vehicles are > > cars, bikes, trucks. > > > I want to select an object from the list with a probability of : cars > > 0.7, bikes 0.3, truck

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
Oh yes as several have pointed out there was a typo in my original question ... I can only blame 'toolongatscreenitis' ! -- http://mail.python.org/mailman/listinfo/python-list

Re: Pick items from list with probability based upon property of list member ?

2010-06-21 Thread southof40
Thanks to everybody ... as usual on c.l.p I'm blown away by the knowledge and skills ! I've added some replies/clarifications to other posts but thanks again to you all. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Carl Banks
On Jun 21, 12:00 am, Dave Angel wrote: > Steven D'Aprano wrote: > > On Sun, 20 Jun 2010 18:21:43 -0400, Dave Angel wrote: > > >> Something's intrinsically wrong with the argument made in this thread > >> against generating assembly code.  That's exactly what happens every > >> time you write code

Re: constructing an object from another instance of the same class

2010-06-21 Thread Jean-Michel Pichavant
Christoph Groth wrote: Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg):

Re: process cannot access the file because it is being used by other process

2010-06-21 Thread Tim Golden
On 21/06/2010 09:23, shanti bhushan wrote: i am using below code ,it works fine on ordinary python 26 ,but when i use this script in my python testing tool it gives me message "process cannot access the file because it is being used by other process" for the second time invoking of mongoose serve

process cannot access the file because it is being used by other process

2010-06-21 Thread shanti bhushan
Hi, i am using below code ,it works fine on ordinary python 26 ,but when i use this script in my python testing tool it gives me message "process cannot access the file because it is being used by other process" for the second time invoking of mongoose server. Please help me in handling this excep

Re: tkInter Listbox question

2010-06-21 Thread eb303
On Jun 21, 7:36 am, Anthony Papillion wrote: > So I'm trying to add a Listbox to my window. I want it to be the width > of my window and the height of my window.  I'm using the following > code ('root' is my toplevel window): > > gsItems = Listbox(root, width=root.winfo_width(), > height=root.winf

Re: plac 0.5 is out!

2010-06-21 Thread Andre Alexander Bell
On 06/21/2010 05:38 AM, Michele Simionato wrote: >>> A few weeks ago I presented on this list my most recent effort, plac. >>> http://micheles.googlecode.com/hg/plac/doc/plac_ext.html >> >> But this one is broken. :( > > Aagh! The good one is > http://micheles.googlecode.com/hg/plac/doc/plac_adv

Re: Generator (re-)definition within a loop

2010-06-21 Thread Pierre Reinbold
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 06/18/2010 11:48 PM, Terry Reedy wrote: > On 6/18/2010 3:57 PM, Pierre Reinbold wrote: > >> def genexp_product(*args): >> pools = map(tuple, args) >> result = [[]] >> for pool in pools: >> result = (x+[y] for x in result for

Re: Is this make sence? Dynamic assembler for python

2010-06-21 Thread Dave Angel
Steven D'Aprano wrote: On Sun, 20 Jun 2010 18:21:43 -0400, Dave Angel wrote: Something's intrinsically wrong with the argument made in this thread against generating assembly code. That's exactly what happens every time you write code in C. I don't know whether C compilers generate a