Re: Need to import stuff

2010-08-17 Thread Abhijeet

Hi,

Used imp. It worked.

Thanks


Daniel Kluev wrote:


On Wed, Aug 18, 2010 at 9:40 AM, abhijeet thatte 
mailto:abhijeet.tha...@gmail.com>> wrote:


Hi,

Thanks for the reply. But I guess it does not support nested file
paths. 
If user gives 'abcd' then I need to import "//*Do/Stuff/abcd*/".

Out of which only /"abcd" is taken run time. Do and Stuff are fixed. /
/I got an error "/ImportError: Import by filename is not
supported.". Any solution??


For complex importing, you can use imp module,
http://docs.python.org/library/imp.html

Like this:
module_desc = imp.find_module(name, [base_path])
module = imp.load_module(full_name, *module_desc)
 
--

With best regards,
Daniel Kluev



--
http://mail.python.org/mailman/listinfo/python-list


Re: Need to import stuff

2010-08-17 Thread Daniel Kluev
On Wed, Aug 18, 2010 at 9:40 AM, abhijeet thatte
wrote:

> Hi,
>
> Thanks for the reply. But I guess it does not support nested file paths.
> If user gives 'abcd' then I need to import "*/Do/Stuff/abcd*". Out of
> which only *"abcd" is taken run time. Do and Stuff are fixed. *
> *I got an error "*ImportError: Import by filename is not supported.". Any
> solution??
>
>
For complex importing, you can use imp module,
http://docs.python.org/library/imp.html

Like this:
module_desc = imp.find_module(name, [base_path])
module = imp.load_module(full_name, *module_desc)

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-17 Thread Cameron Simpson
On 17Aug2010 20:15, Νίκος  wrote:
| ===
| cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page =
| '%s' ORDER BY date DESC ''' % (page) )
| ===
| 
| Someone told me NOT to do string substitution ("%") on SQL statements
| and to let MySQLdb do it
| for me, with proper escaping like the following
| 
| ===
| cursor.execute('''SELECT host, hits, date FROM visitors WHERE page=%s
| ORDER BY date DESC''', (page,))
| ===
| 
| The difference is that if some external source can control "page",
| and
| they put in a value like
| 100 ; DELETE FROM visitors; SELECT * FROM visitors
| i will be losing my database table data.

That other difference is that the mysql dialect support knows how to
correctly escape a string for insertion into an SQL statement. You may
not, or may forget to pre-escape the string, etc. Using the MySQLdb
stuff do it for you is reliable and robust.

| a) I wanted to ask what is proper escaping mean and why after variable
| page syntax has a comma

Because this:

  (page)

means the same thing as:

  page

i.e. the argument to the "%" operator is just the string in page.

This:

  (page,)

is a _tuple_ containing a single element, the page variable.
A bit like:

  [page]

which is a list containing a single element. The trailing comma is
needed to tell python you want to use a tuple, not the bare string.

The "%" operator has special knowledge that is it is passed as string instead
of a list or tuple or other sequence then it should act _as_ _if_ it had been
passed a single element tuple containing the string.

Otherwise, because a string _is_ a sequence the "%" might want to treat
the string "foo" as the sequence:

  ("f", "o", "o")

Run these three loops to see the difference:

  for s in "foo":
print s
  for s in ("foo"):
print s
  for s in ("foo",):
print s

Cheers,
-- 
Cameron Simpson  DoD#743
http://www.cskk.ezoshosting.com/cs/

I couldn't think of anything else to do with it, so I put it on the web.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String substitution VS proper mysql escaping

2010-08-17 Thread Daniel Kluev
2010/8/18 Νίκος 

> a) I wanted to ask what is proper escaping mean and
>
>
Proper escaping means that value is wrapped in quotes properly, and quotes
and backslashes (or any other special to RDBMS symbol) are escaped with
backslashes.

why after variable page syntax has a comma
>

Comma just means its tuple.

(page) is equal to page, while (page,) is one-element tuple which contains
page:

>>> ('123')
'123'
>>> ('123',)
('123',)



> why don't my code as i have it now for string reproduction
>
> ===
> http://webville.gr/index.html?page="100 ; DELETE FROM visitors; SELECT
> * FROM visitors "
> ===
>
> don't reproduce the problem of actual deleting my data. I don't care
> losing it!
>
> I just want to see that happening with my own eyes!
>
>
Your script there just throws an exception for any page data, and most
likely does not run any query at all:

> 28 # open current html template and get the page ID number
> 29 #
> =
> 30 f = open( '/home/webville/public_html/' + page )
> 31
> 32 # read first line of the file
> f undefined, builtin open = , page = ['index.html', '100']
> TypeError: cannot concatenate 'str' and 'list' objects
>

Besides, using user-provided data and just concatenating it to filename like
that is definitely bad idea.
You should use os.path.join() at least.

Regarding that kind of SQL injection, typically driver will stop it to
happen when you provide 2 queries at once delimited by ';', so drop table
would not work. However its possible to issue UNION's to retrieve sensitive
data from your database.

-- 
With best regards,
Daniel Kluev
-- 
http://mail.python.org/mailman/listinfo/python-list


String substitution VS proper mysql escaping

2010-08-17 Thread Νίκος
===
cursor.execute( ''' SELECT host, hits, date FROM visitors WHERE page =
'%s' ORDER BY date DESC ''' % (page) )
===

Someone told me NOT to do string substitution ("%") on SQL statements
and to let MySQLdb do it
for me, with proper escaping like the following

===
cursor.execute('''SELECT host, hits, date FROM visitors WHERE page=%s
ORDER BY date DESC''', (page,))
===

The difference is that if some external source can control "page",
and
they put in a value like
100 ; DELETE FROM visitors; SELECT * FROM visitors
i will be losing my database table data.


a) I wanted to ask what is proper escaping mean and why after variable
page syntax has a comma

and as i have the script now

why don't my code as i have it now for string reproduction

===
http://webville.gr/index.html?page="100 ; DELETE FROM visitors; SELECT
* FROM visitors "
===

don't reproduce the problem of actual deleting my data. I don't care
losing it!

I just want to see that happening with my own eyes!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Russ P.
On Aug 7, 5:54 am, "D'Arcy J.M. Cain"  wrote:

> Would said beginner also be surprised that a newborn baby is zero years
> old or would it be more natural to call them a one year old?  Zero
> based counting is perfectly natural.

You're confusing continuous and discrete variables. Time is a
continuous variable, but a list index is discrete.

Take a look at any numbered list, such as the top ten football teams
or the top ten software companies. Have you ever seen such a list
start with zero? If so, where? I sure haven't.

When I studied linear algebra way back, vector and matrix indices also
always started with one, and I assume they still do.

The convention of starting with zero may have had some slight
performance advantage in the early days of computing, but the huge
potential for error that it introduced made it a poor choice in the
long run, at least for high-level languages.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread John Passaniti
On Aug 17, 4:19 pm, Standish P  wrote:
> > > It is true that the other languages such as F/PS also have borrowed
> > > lists from lisp in the name of nested-dictionaries and mathematica
> > > calls them nested-tables as its fundamental data structure.
>
> > No.
>
> you are contradicting an earlier poster from forth who admitted the
> part on dicts.

Then they are wrong.

You asked if Forth "borrowed" lists from Lisp.  It did not.  In Lisp,
lists are constructed with pair of pointers called a "cons cell".
That is the most primitive component that makes up a list.  Forth has
no such thing; in Forth, the dictionary (which is traditionally, but
not necessarily a list) is a data structure that links to the previous
word with a pointer.  This is in fact one of the nice things about
Lisp; because all lists are created out of the same primitive cons
cell, you can consistently process any list in the system.  In Forth,
any lists (such as the dictionary, if it is a list) are specific to
their purpose and have to be treated individually.

I don't know what you mean by "nested-dictionaries."  There is no such
thing in Forth.  Dictionaries don't nest.  You can create wordlists,
but each wordlist is flat.  When most people think of a nested
dictionary, they would think of a structure that would allow any
arbitrary level of nesting, not a string of flat wordlists.

> > > The whole case of OOP is the clustering of thought, ie book-keeping,
> > > in the mind of the programmer around fewer objects than ten or twenty
> > > fold functions.
>
> > That's one view of OOP.  It's not the only one.
>
> and what can you add to enlighten the readers on the other view ?

How one views OOP depends on the language and implementation.  Your
statement about having fewer than "ten or twenty fold" functions is
completely arbitrary and is more a matter of style and skill in
decomposition than an intrinsic quality about objects.  The poetic
"clustering of thought" is vague but a I guess could be an informal
notion of the bundling of related state and methods.  And referring to
it as "book-keeping" suggests some kind of static relationship between
state and methods, although that is not the case in architectures that
stress dynamic relationships.  Many people only know OOP through
static, class-based models (such as in languages like C++).  But there
are other models.  Objects can also be represented not with classes
but by cloning existing objects and then mutating them as needed.
Objects can also be represented with a functional interface using a
closure around an environment.  In such cases, objects may be far more
fluid than in static class-based models, and shift over time into
different roles.  In such systems, "book-keeping" isn't static.  Or
put another way, the language and implementation drive the flavor that
a particular object has.

> > You, like probably everyone else who has thought about how to
> > "simplify" languages will eventually end up at the same place-- you'll
> > have a model that meets your objectives, but with some programmers
> > will find is unnecessarily limiting.  More importantly, you'll run
> > into some classes of problems for which your simple model makes things
> > inordinately complicated relative to what other languages and
> > paradigms offer.
>
> The objective is to discuss those cases via specific examples (not
> generalities), and talk ABOUT them, not AROUND them.

I'd be happy to discuss specific examples, but your understanding of
Forth is flawed, and until you learn more about Forth, I don't think
it would be helpful.

And actually, I did provide a specific example.  You apparently didn't
understand it, so let me be more explicit.  Here is a function in
Scheme:

(define (hello name)
(lambda ()
(begin
(display "Hello ")
(display name

This defines a function that returns another function.  You can think
of this as a constructor for a light-weight object that has one value
("name") and one default method (to print "Hello ").  The
function that is returned can be stored, passed around, and otherwise
out-live the invocation of this function.  For example:

(define example (hello "John"))

In your stack mindset, the value "John" would disappear after the call
to "hello".  But in Scheme, the value lives on, as it is part of the
closure captured at the time the function was created.

A stack mindset would not allow this.  And this would eliminate the
vast majority of functional programming from your language's
abilities.  Maybe you don't care, or maybe you still don't see the
value in this.  In that case, I suggest you learn the language and
then think about what your stack mindset prevents.

> > Here's a better idea:  
>
> Its a very fine wild goose chase project statement.

No, it is a vivid example of what you don't know-- and what you don't
know is what will limit you later.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about pdb assignment statements

2010-08-17 Thread Steve Ferg
Thanks mucho!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: update of elements in GUI

2010-08-17 Thread woooee
On Aug 16, 9:07 pm, Jah_Alarm  wrote:
> hi, I've already asked this question but so far the progress has been
> small.
>
> I'm running Tkinter. I have some elements on the screen (Labels, most
> importantly) which content has to be updated every iteration of the
> algorithm run, e.g. "Iteration =" [i] for i in range(n), n=100. I'm
> using the update_idletasks() command in the function itself after the
> variable.set(...) command. The variable type is IntVar(), and the
> mistake I'm getting is 'IntVar instance has no attribute
> 'update_idletasks'. No updates are displayed, of course.
>
> Without the GUI the algorithm (it's a genetic algorithm) is working
> fine, but I need to make it available to other people via GUI
>
> cheers,
>
> Alex

This program I had lying around and it will hopefully make things
clearer.  The integer under the second label (i.e. the 3rd label)
increases by on every time you click the "Print Contents" button.  The
variable associated with the second label and the entry box update as
you change the entry box's contents, all with no calls to
update_idletasks().
class EntryTest:
""" shows using the same StringVar in the second list box
and in the entry box
"""
def __init__(self):
self.top = Tkinter.Tk()
self.top.title("Test of Entry")
self.top.geometry("200x150+10+10")

self.str_1 = Tkinter.StringVar()
label_lit = Tkinter.StringVar()
self.int_lit = Tkinter.IntVar()

label_1 = Tkinter.Label(self.top, textvariable = label_lit )
label_1.pack()
label_lit.set( "Test of Label")

label_2 = Tkinter.Label(self.top, textvariable = self.str_1 )
label_2.pack()

label_3 = Tkinter.Label(self.top, textvariable =
self.int_lit )
label_3.pack()
self.int_lit.set(0)

entry_1 = Tkinter.Entry(self.top, textvariable=self.str_1)
entry_1.pack()
self.str_1.set( "Entry Initial Value" )

print_button = Tkinter.Button(self.top, text='PRINT CONTENTS',
 command=self.getit, bg='blue', fg='white' )
print_button.pack(fill=Tkinter.X, expand=1)

exit_button= Tkinter.Button(self.top, text='EXIT',
   command=self.top.quit, bg='red', fg='white' )
exit_button.pack(fill=Tkinter.X, expand=1)

entry_1.focus_set()
self.top.mainloop()

   ##-
   def getit(self) :
   print "getit: variable passed =", self.str_1.get()
   x = self.int_lit.get()
   self.int_lit.set(x+1)


##===
if "__main__" == __name__  :
ET=EntryTest()
print "under __main__ =", ET.str_1.get()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subprocess.Popen calling httpd reload never finishes

2010-08-17 Thread Albert Hopkins
On Tue, 2010-08-17 at 12:55 -0700, Nan wrote:
> Hi folks --
> 
> I have a Python script running under Apache/mod_wsgi that needs to
> reload Apache configs as part of its operation.  The script continues
> to execute after the subprocess.Popen call.  The communicate() method
> returns the correct text ("Reloading httpd: [  OK  ]"), and I get a
> returncode of 0.  But the python script (Django) that calls Popen
> never seems to complete (by returning an HTTP response.
> 
> Any other Popen call I've tried exits properly.  Here's some sample
> code:
> 
>   args = ['sudo /etc/init.d/httpd reload']
>   proc = subprocess.Popen(args, stdin=subprocess.PIPE,
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
> close_fds=True)
>   (stdout_txt, stderr_txt) = proc.communicate("")
>   proc.wait()
>   logging.debug('%d %s%s' % (proc.returncode, stdout_txt,
> stderr_txt))
>   logging.debug('still executing')
>   return HttpResponse('done')
> 
> The logging statements are output, but the script doesn't exit.  If
> you substitute "sudo ls -l" or "sudo /etc/init.d/httpd configtest" for
> "sudo /etc/init.d/httpd reload", the exits properly.
> 
>  Any idea what I might be doing wrong?
> 
> Thanks!

Django runs inside apache.  It's kinda weird to have an apache process
restart itself and expect it to return to the caller.

If the init script does like mine, "reload" executes "apachectl -k
graceful"   What that instructs apache to do is to restart, but only
kill the process(es) when there are no more connections.  So apache is
waiting for your connection to close, but you are inside an HTTP request
waiting for apache to restart.  So you have a race condition here.

It's not advisable to have apache kill itself and expect it to send a
status back to you telling you it's dead.

See the apache docs[1] for a better explanation.


http://httpd.apache.org/docs/2.0/stopping.html#graceful


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 0 length field in time string

2010-08-17 Thread MRAB

Rodrick Brown wrote:
Anyone know why I'm getting the following error when trying to parse the 
following string is there a better method to use? 


#57=2010081708240065 - sample string passed to fmt_datetime
 
def fmt_datetime(tag57):

tag57   = tag57[3:len(tag57)]
year= int ( tag57[0:4] )
mon = int ( tag57[4:6] )
day = int ( tag57[6:8])
hour= int ( tag57[8:10] )
min = int ( tag57[10:12>] )
sec = int ( tag57[12:14>] )
msec= int ( tag57[14:16] )


You could use:

dt = datetime.datetime.strptime(tag57[3 : 17], "%Y%m%d%H%M%S")


dt  = datetime.datetime(year,mon,day,hour,min,sec)
return '{:%Y-%m-%d %H:%M:%S}'.format(dt)

  File "./delta_delay.py", line 27, in fmt_datetime
return '{:%Y-%m-%d %H:%M:%S}'.format(dt)
ValueError: zero length field name in format
 

You haven't supplied an argument name or position (required in Python
2.6):

return '{0:%Y-%m-%d %H:%M:%S}'.format(dt)
--
http://mail.python.org/mailman/listinfo/python-list


0 length field in time string

2010-08-17 Thread Rodrick Brown
Anyone know why I'm getting the following error when trying to parse the 
following string is there a better method to use? 

#57=2010081708240065 - sample string passed to fmt_datetime
 
def fmt_datetime(tag57):
tag57   = tag57[3:len(tag57)]
year= int ( tag57[0:4] )
mon = int ( tag57[4:6] )
day = int ( tag57[6:8])
hour= int ( tag57[8:10] )
min = int ( tag57[10:12] )
sec = int ( tag57[12:14] )
msec= int ( tag57[14:16] )

dt  = datetime.datetime(year,mon,day,hour,min,sec)
return '{:%Y-%m-%d %H:%M:%S}'.format(dt)

  File "./delta_delay.py", line 27, in fmt_datetime
return '{:%Y-%m-%d %H:%M:%S}'.format(dt)
ValueError: zero length field name in format
 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 2:29 am, Raymond Hettinger  wrote:

> I would like to see someone post a subclass to the ASPN Cookbook that
> adds a number of interesting, though not common operations.  Your
> symmetric_difference() method could be one.  A dot_product() operation
> could be another.  Elementwise arithmetic is another option (we
> already have add and subtract, but could possibly use multiply,
> divide, etc).  Scaling operations are another possibility (multiple
> all elements by five, for example).
>

>
> Raymond

Sample code is at 
http://code.activestate.com/recipes/577362-extension-to-python-3-counter-class/
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Need to import stuff

2010-08-17 Thread abhijeet thatte
Hi,

Thanks for the reply. But I guess it does not support nested file paths.
If user gives 'abcd' then I need to import "*/Do/Stuff/abcd*". Out of which
only *"abcd" is taken run time. Do and Stuff are fixed. *
*I got an error "*ImportError: Import by filename is not supported.". Any
solution??

On Tue, Aug 17, 2010 at 3:27 PM, Jerry Hill  wrote:

> On Tue, Aug 17, 2010 at 6:21 PM, abhijeet thatte
>  wrote:
> > Hi,
> > I need to import few files depending on the user input. For eg if user
> gives
> > an input as "abcd" then I will have  import "abcd.py".
> > Can not have any hard coding in the code. Does any one know how to solve
> the
> > problem.
>
> Use the __import__ function (
> http://docs.python.org/library/functions.html#__import__ ), like this:
>
> user_module = __import__("abdc")
> user_module.do_stuff()
>
> --
> Jerry
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On Aug 17, 10:47 pm, Paddy  wrote:
> On 17 Aug, 02:29, Raymond Hettinger  wrote:
>
>
>
> > [Paddy]
>
> > > Lets say you have two *sets* of integers representing two near-copies
> > > of some system, then a measure of their difference could be calculated
> > > as:
>
> > > len(X.symmetric_difference(Y)) / (len(X) + len(Y)) * 100 %
>
> > > If the two collections of integers are allowed duplicates then you
> > > need a Counter/bag/multi-set type and the diff calculation I gave
> > > originally.
>
> > Thanks for sharing your use case.
>
> > It's unlikely that I will add this method to the Counter API because
> > the rarity of use case does not warrant the added API complexity.
> > IMO, adding a method like this makes the class harder to learn,
> > understand and remember.  It doesn't seem like much of a win over
> > using the existing alternatives:
>
> >  * (b - c) + (c - b)
> >  * (b | c) - (b & c)
> >  * DIY using the two counters as simple dicts
> >  * writing a subclass providing additional binary operations
>
> > I would like to see someone post a subclass to the ASPN Cookbook that
> > adds a number of interesting, though not common operations.  Your
> > symmetric_difference() method could be one.  A dot_product() operation
> > could be another.  Elementwise arithmetic is another option (we
> > already have add and subtract, but could possibly use multiply,
> > divide, etc).  Scaling operations are another possibility (multiple
> > all elements by five, for example).
>
> > The Counter() class has low aspirations.  It is a dictionary that
> > fills-in missing values with zero and is augmented by a handful of
> > basic methods for managing the counts.
>
> > Raymond
>
> I created this that could be an addition to the bottom of the Python 3
> collections.Counter class definition:
>
>     def __xor__(self, other):
>         ''' symmetric difference: Subtract count, but keep only abs
> results with non-zero counts.
>
>         >>> Counter('abbbc') ^ Counter('bccd')
>         Counter({'b': 2, 'a': 1, 'c': 1, 'd': 1})
>         >>> a, b = Counter('abbbc'), Counter('bccd')
>         >>> (a-b) + (b - a) == a ^ b
>         True
>
>         '''
>         if not isinstance(other, Counter):
>             return NotImplemented
>         result = Counter()
>         for elem in set(self) | set(other):
>             newcount = self[elem] - other[elem]
>             if newcount != 0:
>                 result[elem] = newcount if newcount > 0 else -newcount
>         return result
>
> - Paddy.

And heres the cartesian product/multiply:

def __mul__(self, other):
'''Multiply counts by an integer; or cartesioan product
of two counters.

>>> Counter('abbb') * 3
Counter({'b': 9, 'a': 3})
>>> Counter('12') * Counter('21')
Counter({('2', '1'): 1, ('1', '2'): 1, ('1', '1'): 1, ('2',
'2'): 1})
>>> Counter('122') * Counter('211')
Counter({('2', '1'): 4, ('1', '1'): 2, ('2', '2'): 2, ('1',
'2'): 1})
'''
if isinstance(other, int):
return Counter(**dict((k, v*other)
  for k,v in self.items()))
elif isinstance(other, Counter):
return Counter( (x, y)
for x in self.elements()
for y in other.elements() )
else:
return NotImplemented

(Although I don't have a use case for this one).

- Paddy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need to import stuff

2010-08-17 Thread Jerry Hill
On Tue, Aug 17, 2010 at 6:21 PM, abhijeet thatte
 wrote:
> Hi,
> I need to import few files depending on the user input. For eg if user gives
> an input as "abcd" then I will have  import "abcd.py".
> Can not have any hard coding in the code. Does any one know how to solve the
> problem.

Use the __import__ function (
http://docs.python.org/library/functions.html#__import__ ), like this:

user_module = __import__("abdc")
user_module.do_stuff()

-- 
Jerry
-- 
http://mail.python.org/mailman/listinfo/python-list


Need to import stuff

2010-08-17 Thread abhijeet thatte
Hi,

I need to import few files depending on the user input. For eg if user gives
an input as "abcd" then I will have * import "abcd.py".*
Can not have any hard coding in the code. Does any one know how to solve the
problem.

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread geremy condra
On Tue, Aug 17, 2010 at 7:59 AM, Lie Ryan  wrote:
> On 08/16/10 21:54, David Cournapeau wrote:
>> On Mon, Aug 16, 2010 at 9:53 AM, Gregory Ewing
>>  wrote:
 On Aug 7, 2010, at 9:14 PM, John Nagle wrote:

>  The languages which have real multidimensional arrays, rather
> than arrays of arrays, tend to use 1-based subscripts.  That
> reflects standard practice in mathematics.
>>>
>>> Not always -- mathematicians use whatever starting index is
>>> most convenient for the problem at hand.
>>
>> Yes, there are many engineering fields where index starts at 0. Partly
>> for the reason you have stated concerning polynomials, especially
>> since this extend to series, which are pervasive in numerical
>> computing. In linear algebra, though, I remember to have always noted
>> matrices indexes in the [1,n] range, not [0,n-1].
>
> I'm sure some would prefer to denote it as [0, n)

Count me in on that, that'd be great.

Geremy Condra
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Nobody
On Mon, 16 Aug 2010 22:35:49 -0400, AK wrote:

> As monitors are getting bigger, is there a general change in opinion on
> the 79 chars limit in source files? I've experimented with 98 characters
> per line and I find it quite a bit more comfortable to work with that
> length, even though sometimes I have to edit files in 80 width
> terminals, it's still easier to adapt to some inconvenience when that
> happens than the other way around, since about 95% of time or more, I do
> use wider editor window or terminal.
> 
> Is going over 79 still a terrible thing to do?  -andrei

If the the limit isn't 79, then what is it? Or are 1000-column lines okay?

Often, simply having a convention is more important than the precise
details. E.g. I don't particularly care how I configure my text editor's
auto-formatting settings, but I do care about not having to change those
settings for each file.

For code which will never be read or edited by anyone other than yourself,
use whatever conventions you want. If you're going to publish the code,
it's a good idea to stick to established standards (80-column lines,
8-column tabs, no gratuitous use of non-ASCII characters, etc).

Apart from "altruistic" reasons, bear in mind that the next time you apply
for a job, the employer may look at your code not just to determine your
programming competence, but also whether you're likely to be a "team
player". Code which doesn't follow normal conventions says "I've only ever
worked on my own, not with other people".

I can't stress enough how big a factor this is. Writing code by yourself
and working as part of a team are almost entirely different skills. Anyone
who regularly hires programmers will be only too aware of the difference.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Roy Smith
In article <4c6a8cf...@dnews.tpgi.com.au>,
 Lie Ryan  wrote:

> On 08/16/10 21:54, David Cournapeau wrote:
> > On Mon, Aug 16, 2010 at 9:53 AM, Gregory Ewing
> >  wrote:
> >>> On Aug 7, 2010, at 9:14 PM, John Nagle wrote:
> >>>
>   The languages which have real multidimensional arrays, rather
>  than arrays of arrays, tend to use 1-based subscripts.  That
>  reflects standard practice in mathematics.
> >>
> >> Not always -- mathematicians use whatever starting index is
> >> most convenient for the problem at hand.
> > 
> > Yes, there are many engineering fields where index starts at 0. Partly
> > for the reason you have stated concerning polynomials, especially
> > since this extend to series, which are pervasive in numerical
> > computing. In linear algebra, though, I remember to have always noted
> > matrices indexes in the [1,n] range, not [0,n-1].
> 
> I'm sure some would prefer to denote it as [0, n)

Only if there's an emacs mode which can do the parenthesis matching 
correctly ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Roy Smith
In article ,
 Martin Gregorie  wrote:

> > Roy wasn't using numpy/Python semantics but made-up semantics (following
> > Martin Gregorie's made-up semantics to which he was replying) which
> > treat the step size as a true size, not a size and direction. The
> > direction is determined from the start and stop parameters. It's an
> > almost-reasonable design.
> 
> That wasn't a made-up example: AFAICR and ignoring a missing semi-colon 
> it was an Algol 68 snippet.

It was a made up example.  Any similarity to a real programming 
language, living or dead, was purely a coincidence.

I suspect I've probably also written a viable code snippet in Whitespace 
as well (http://compsoc.dur.ac.uk/whitespace/).  That, too, is a 
coincidence.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EXOR or symmetric difference for the Counter class

2010-08-17 Thread Paddy
On 17 Aug, 02:29, Raymond Hettinger  wrote:
> [Paddy]
>
> > Lets say you have two *sets* of integers representing two near-copies
> > of some system, then a measure of their difference could be calculated
> > as:
>
> > len(X.symmetric_difference(Y)) / (len(X) + len(Y)) * 100 %
>
> > If the two collections of integers are allowed duplicates then you
> > need a Counter/bag/multi-set type and the diff calculation I gave
> > originally.
>
> Thanks for sharing your use case.
>
> It's unlikely that I will add this method to the Counter API because
> the rarity of use case does not warrant the added API complexity.
> IMO, adding a method like this makes the class harder to learn,
> understand and remember.  It doesn't seem like much of a win over
> using the existing alternatives:
>
>  * (b - c) + (c - b)
>  * (b | c) - (b & c)
>  * DIY using the two counters as simple dicts
>  * writing a subclass providing additional binary operations
>
> I would like to see someone post a subclass to the ASPN Cookbook that
> adds a number of interesting, though not common operations.  Your
> symmetric_difference() method could be one.  A dot_product() operation
> could be another.  Elementwise arithmetic is another option (we
> already have add and subtract, but could possibly use multiply,
> divide, etc).  Scaling operations are another possibility (multiple
> all elements by five, for example).
>
> The Counter() class has low aspirations.  It is a dictionary that
> fills-in missing values with zero and is augmented by a handful of
> basic methods for managing the counts.
>
> Raymond

I created this that could be an addition to the bottom of the Python 3
collections.Counter class definition:

def __xor__(self, other):
''' symmetric difference: Subtract count, but keep only abs
results with non-zero counts.

>>> Counter('abbbc') ^ Counter('bccd')
Counter({'b': 2, 'a': 1, 'c': 1, 'd': 1})
>>> a, b = Counter('abbbc'), Counter('bccd')
>>> (a-b) + (b - a) == a ^ b
True

'''
if not isinstance(other, Counter):
return NotImplemented
result = Counter()
for elem in set(self) | set(other):
newcount = self[elem] - other[elem]
if newcount != 0:
result[elem] = newcount if newcount > 0 else -newcount
return result

- Paddy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-17 Thread Baba
On Aug 16, 6:28 pm, "cbr...@cbrownsystems.com"
 wrote:

> First, suppose d = gcd(x, y, z); then for some x', y', z' we have that
> x = d*x', y = d*y', z = d*z'; and so for any a, b, c:
>


   could you explain the notation?

   what is the difference btw x and x' ?

   what is x = d*x', y supposed to say?



> To go the other way, if d = 1, then there exists integers (not
> neccessarily positive) such that
>
> a*x + b*y + c*z = 1
>


   what's the link with 6*a+9*b+20*c=n except the similarity?



furthermore i came across this:

For k = 3, efficient algorithms
have been given by Greenberg and Davison ; if x1 < x2 < x3, these
algorithms run in
time bounded by a polynomial in log x3. Kannan  gave a very
complicated algorithm
that runs in polynomial time in log xk if k is fixed, but is wildly
exponential in k. However,
Ram´ırez Alfons´ın proved that the general problem is NP-hard, under
Turing reductions,
by reducing from the integer knapsack problem. So it seems very likely
that there is no
simple formula for computing g(x1, x2, . . . , xk) for arbitrary k.

source: http://arxiv.org/PS_cache/arxiv/pdf/0708/0708.3224v1.pdf


i would be interested in the answer to problem 3: explain in English
why the theorem is true

@Giacomo: when you say that i have not read the text of the assignment
i tend to disagree. Therefore could you point out what it is i
overlooked that should help me prove my assumption for the
generalisation? Enjoy the sausages btw :)

tnx
Baba






-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for an appropriate encoding standard that supports all languages

2010-08-17 Thread Thomas Jollans
On Tuesday 17 August 2010, it occurred to ata.jaf to exclaim:
> I am developing a little program in Mac with wxPython.
> But I have problems with the characters that are not in ASCII. Like
> some special characters in French or Turkish.
> So I am looking for a way to solve this. Like an encoding standard
> that supports all languages. Or some other way.

Anything that supports all of Unicode will do. Like UTF-8. If your text is 
mostly Latin, then just go for UTF-8, if you use other alphabets extensively, 
you might want to consider UTF-16, which might the use a little less space.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Elizabeth D Rather

On 8/17/10 10:19 AM, Standish P wrote:

On Aug 17, 12:32 pm, John Passaniti  wrote:

...

It is true that the other languages such as F/PS also have borrowed
lists from lisp in the name of nested-dictionaries and mathematica
calls them nested-tables as its fundamental data structure.


No.


you are contradicting an earlier poster from forth who admitted the
part on dicts.


Not at all.  A Forth dictionary is a simple linked list, not the 
complicated kind of nested structures you're referring to.  You really 
seem addicted to very complex structures.  They really aren't necessary 
for general programming.


Cheers,
Elizabeth

--
==
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==
--
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 1:19 pm, Standish P  wrote:
> On Aug 17, 12:32 pm, John Passaniti  wrote:
>
>
>
>
>
> > On Aug 17, 2:53 pm, Standish P  wrote:
>
> > > Another way to pose my question, as occurred to me presently is
> > > to ask if a stack is a good abstraction for programming ?
> > > Certainly, it is the main abstraction in Forth and Postscript
> > > and implementable readily in C,C++ and I assume python.
>
> > A stack is a fine abstraction for some kinds of programming.  It fails
> > for others.  In languages where functions are first-class entities
> > that can be stored and passed around like any other kind of data,
> > stacks can be problematic because a function can out-live the stack
> > frame they were created in.
>
> > > It is true that the other languages such as F/PS also have borrowed
> > > lists from lisp in the name of nested-dictionaries and mathematica
> > > calls them nested-tables as its fundamental data structure.
>
> > No.
>
> you are contradicting an earlier poster from forth who admitted the
> part on dicts.
>
>
>
> > > The whole case of OOP is the clustering of thought, ie book-keeping,
> > > in the mind of the programmer around fewer objects than ten or twenty
> > > fold functions.
>
> > That's one view of OOP.  It's not the only one.
>
> and what can you add to enlighten the readers on the other view ?
>
>
>
> > > so the name of the game is the same, ie to help the programmer keep
> > > track of things for writing fault free code without chasing every
> > > case, easy visualization, easy recall and communication with fellow
> > > programmers of abstract concepts in terms of real world objects and
> > > easy modification and code reuse.
>
> > You, like probably everyone else who has thought about how to
> > "simplify" languages will eventually end up at the same place-- you'll
> > have a model that meets your objectives, but with some programmers
> > will find is unnecessarily limiting.  More importantly, you'll run
> > into some classes of problems for which your simple model makes things
> > inordinately complicated relative to what other languages and
> > paradigms offer.
>
> The objective is to discuss those cases via specific examples (not
> generalities), and talk ABOUT them, not AROUND them.
>
> > Here's a better idea:  
>
> Its a very fine wild goose chase project statement.
>
>
>
> > Become familiar with the languages you've
> > cited, and more.  I would recommend Forth, Lisp, Smalltalk or Ruby,
> > Lua or JavaScript.  Learn each and then come back and tell us if you
> > think limiting the programmer to objects with stack-ordered lifetimes
> > is enough.  Oh, and while you're at it, dip your toes into a problem
> > domain you don't normally do any work in.  If you're an embedded
> > systems guy, then spend some time writing a non-trivial web
> > application.  Go outside your comfort zone and find a problem domain
> > where cherished idioms and tools no longer apply.  I think it will
> > open your eyes

program a universe simulator using a turing machine.

-- 
http://mail.python.org/mailman/listinfo/python-list


Looking for an appropriate encoding standard that supports all languages

2010-08-17 Thread ata.jaf
I am developing a little program in Mac with wxPython.
But I have problems with the characters that are not in ASCII. Like
some special characters in French or Turkish.
So I am looking for a way to solve this. Like an encoding standard
that supports all languages. Or some other way.

Thanks
Ata Jafari
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 12:32 pm, John Passaniti  wrote:
> On Aug 17, 2:53 pm, Standish P  wrote:
>
> > Another way to pose my question, as occurred to me presently is
> > to ask if a stack is a good abstraction for programming ?
> > Certainly, it is the main abstraction in Forth and Postscript
> > and implementable readily in C,C++ and I assume python.
>
> A stack is a fine abstraction for some kinds of programming.  It fails
> for others.  In languages where functions are first-class entities
> that can be stored and passed around like any other kind of data,
> stacks can be problematic because a function can out-live the stack
> frame they were created in.
>
> > It is true that the other languages such as F/PS also have borrowed
> > lists from lisp in the name of nested-dictionaries and mathematica
> > calls them nested-tables as its fundamental data structure.
>
> No.

you are contradicting an earlier poster from forth who admitted the
part on dicts.

>
> > The whole case of OOP is the clustering of thought, ie book-keeping,
> > in the mind of the programmer around fewer objects than ten or twenty
> > fold functions.
>
> That's one view of OOP.  It's not the only one.

and what can you add to enlighten the readers on the other view ?

>
> > so the name of the game is the same, ie to help the programmer keep
> > track of things for writing fault free code without chasing every
> > case, easy visualization, easy recall and communication with fellow
> > programmers of abstract concepts in terms of real world objects and
> > easy modification and code reuse.
>
> You, like probably everyone else who has thought about how to
> "simplify" languages will eventually end up at the same place-- you'll
> have a model that meets your objectives, but with some programmers
> will find is unnecessarily limiting.  More importantly, you'll run
> into some classes of problems for which your simple model makes things
> inordinately complicated relative to what other languages and
> paradigms offer.

The objective is to discuss those cases via specific examples (not
generalities), and talk ABOUT them, not AROUND them.

> Here's a better idea:  

Its a very fine wild goose chase project statement.

> Become familiar with the languages you've
> cited, and more.  I would recommend Forth, Lisp, Smalltalk or Ruby,
> Lua or JavaScript.  Learn each and then come back and tell us if you
> think limiting the programmer to objects with stack-ordered lifetimes
> is enough.  Oh, and while you're at it, dip your toes into a problem
> domain you don't normally do any work in.  If you're an embedded
> systems guy, then spend some time writing a non-trivial web
> application.  Go outside your comfort zone and find a problem domain
> where cherished idioms and tools no longer apply.  I think it will
> open your eyes.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open a command pipe for reading

2010-08-17 Thread Thomas Jollans
On Tuesday 17 August 2010, it occurred to Rodrick Brown to exclaim:
> I have a fairly large file 1-2GB in size that I need to process line by
> line but I first need to convert the file to text using a 3rd party tool
> that prints the records also line by line.
> 
> I've tried using Popen to do this with no luck. I'm trying to simulate
> 
> /bin/foo myfile.dat
> 
> And as the records are being printed do some calculations.
> 
> pipe = Popen(exttool,shell=True,stdout=PIPE).stdout
> 
> for data in pipe.readlines():
> print data,
> 
> This operation blocks forever I'm guessing it's trying to process the
> entire file at once.

Yes. It is. That's what you're telling it to do: file.readline returns a list 
of all the lines in the file.

What you want to do is iterate over the stream, as in:

for line in pipe:
process(line)

Also, there's probably no need to use shell=True.



> 
> Sent from my iPhone 4.

Is that a fact? This is so interesting.
Phones these days. Almost as annoyingly obnoxious as gmx and yahoo mail.
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess.Popen calling httpd reload never finishes

2010-08-17 Thread Nan
Hi folks --

I have a Python script running under Apache/mod_wsgi that needs to
reload Apache configs as part of its operation.  The script continues
to execute after the subprocess.Popen call.  The communicate() method
returns the correct text ("Reloading httpd: [  OK  ]"), and I get a
returncode of 0.  But the python script (Django) that calls Popen
never seems to complete (by returning an HTTP response.

Any other Popen call I've tried exits properly.  Here's some sample
code:

args = ['sudo /etc/init.d/httpd reload']
proc = subprocess.Popen(args, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True,
close_fds=True)
(stdout_txt, stderr_txt) = proc.communicate("")
proc.wait()
logging.debug('%d %s%s' % (proc.returncode, stdout_txt,
stderr_txt))
logging.debug('still executing')
return HttpResponse('done')

The logging statements are output, but the script doesn't exit.  If
you substitute "sudo ls -l" or "sudo /etc/init.d/httpd configtest" for
"sudo /etc/init.d/httpd reload", the exits properly.

 Any idea what I might be doing wrong?

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Open a command pipe for reading

2010-08-17 Thread Chris Rebert
On Tue, Aug 17, 2010 at 9:40 AM, Rodrick Brown  wrote:
> I have a fairly large file 1-2GB in size that I need to process line by line 
> but I first need to convert the file to text using a 3rd party tool that 
> prints the records also line by line.
>
> I've tried using Popen to do this with no luck. I'm trying to simulate
>
> /bin/foo myfile.dat
>
> And as the records are being printed do some calculations.
>
> pipe = Popen(exttool,shell=True,stdout=PIPE).stdout

I'd strongly suggest trying to avoid shell=True.

> for data in pipe.readlines():

for data in pipe:

>    print data,
>
> This operation blocks forever I'm guessing it's trying to process the entire 
> file at once.

Indeed, that's how readlines() works, so don't use it.
http://docs.python.org/tutorial/inputoutput.html#methods-of-file-objects

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 2.6.6 release candidate 2 now available.

2010-08-17 Thread Barry Warsaw
Hello fellow Python enthusiasts,

The source tarballs and Windows installers for the second (and hopefully last)
Python 2.6.6 release candidate is now available:

http://www.python.org/download/releases/2.6.6/

We've had a handful of important fixes since rc1, and of course a huge number
of bugs have been fixed since 2.6.5, with the full NEWS file available here:

http://www.python.org/download/releases/2.6.6/NEWS.txt

We would love it if you can download, install, and test this version with your
favorite projects and on your favorite platforms.  We expect to release Python
2.6.6 final on August 24, 2010.

Please note that with the release of Python 2.7 final on July 3, 2010, and in
accordance with Python policy, Python 2.6.6 is the last scheduled bug fix
maintenance release of the 2.6 series.  Because of this, your testing of this
release candidate will help immensely.  We plan on continuing to support
source-only security fixes in Python 2.6 for the next five years.

My thanks go out to everyone who has contributed with code, testing and bug
tracker gardening for Python 2.6.6.  The excellent folks on #python-dev are
true Pythonic heros.

Enjoy,
-Barry
(on behalf of the Python development community)


signature.asc
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread AK

On 08/17/2010 03:32 PM, Stefan Schwarzer wrote:

Hi Andrei,

On 2010-08-17 18:43, AK wrote:

But let me ask you, would you really prefer to have:


 self.expiration_date = translate_date(
   find(response, 'MPNExpirationDate').text,
   '%Y-%m-%d', '%m%d%Y')


(or the 4-line version of this above), even when it necessitates
creation of a new function, rather than have this code on two lines?


Given that the reformatted code is three lines and the
former code two lines, I probably wouldn't change anything
but the formatting as shown. :)


After all, I think it's a matter of balance between readability,
expressiveness and succinctness. If I split a function in two, that
still means that understanding the functionality of the code will
require scrolling around and looking at the second function. I guess
what I'm trying to say that we shouldn't just care about readability of
lines but also readability of functions and blocks of functionality
(that may include several functions that accomplish a single "task".)


I think you're right here; you should keep the overall
readability or (maintainability on the whole) in mind.

I agree with Neil that good refactoring can _improve_ the
understandability of the code, and it won't necessarily
require you to look up the code of the extracted
function or method.


I can certainly agree with that - although this sort of refactoring 
(when I do it) is driven by the logic of the code rather than the need 
to spread a long line over several lines :-). -andrei

--
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Stefan Schwarzer
Hi Andrei,

On 2010-08-17 18:43, AK wrote:
> But let me ask you, would you really prefer to have:
> 
 self.expiration_date = translate_date(
   find(response, 'MPNExpirationDate').text,
   '%Y-%m-%d', '%m%d%Y')
> 
> (or the 4-line version of this above), even when it necessitates
> creation of a new function, rather than have this code on two lines?

Given that the reformatted code is three lines and the
former code two lines, I probably wouldn't change anything
but the formatting as shown. :)

> After all, I think it's a matter of balance between readability,
> expressiveness and succinctness. If I split a function in two, that
> still means that understanding the functionality of the code will
> require scrolling around and looking at the second function. I guess
> what I'm trying to say that we shouldn't just care about readability of
> lines but also readability of functions and blocks of functionality
> (that may include several functions that accomplish a single "task".)

I think you're right here; you should keep the overall
readability or (maintainability on the whole) in mind.

I agree with Neil that good refactoring can _improve_ the
understandability of the code, and it won't necessarily
require you to look up the code of the extracted
function or method.

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread John Passaniti
On Aug 17, 2:53 pm, Standish P  wrote:
> Another way to pose my question, as occurred to me presently is
> to ask if a stack is a good abstraction for programming ?
> Certainly, it is the main abstraction in Forth and Postscript
> and implementable readily in C,C++ and I assume python.

A stack is a fine abstraction for some kinds of programming.  It fails
for others.  In languages where functions are first-class entities
that can be stored and passed around like any other kind of data,
stacks can be problematic because a function can out-live the stack
frame they were created in.

> It is true that the other languages such as F/PS also have borrowed
> lists from lisp in the name of nested-dictionaries and mathematica
> calls them nested-tables as its fundamental data structure.

No.

> The whole case of OOP is the clustering of thought, ie book-keeping,
> in the mind of the programmer around fewer objects than ten or twenty
> fold functions.

That's one view of OOP.  It's not the only one.

> so the name of the game is the same, ie to help the programmer keep
> track of things for writing fault free code without chasing every
> case, easy visualization, easy recall and communication with fellow
> programmers of abstract concepts in terms of real world objects and
> easy modification and code reuse.

You, like probably everyone else who has thought about how to
"simplify" languages will eventually end up at the same place-- you'll
have a model that meets your objectives, but with some programmers
will find is unnecessarily limiting.  More importantly, you'll run
into some classes of problems for which your simple model makes things
inordinately complicated relative to what other languages and
paradigms offer.

Here's a better idea:  Become familiar with the languages you've
cited, and more.  I would recommend Forth, Lisp, Smalltalk or Ruby,
Lua or JavaScript.  Learn each and then come back and tell us if you
think limiting the programmer to objects with stack-ordered lifetimes
is enough.  Oh, and while you're at it, dip your toes into a problem
domain you don't normally do any work in.  If you're an embedded
systems guy, then spend some time writing a non-trivial web
application.  Go outside your comfort zone and find a problem domain
where cherished idioms and tools no longer apply.  I think it will
open your eyes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Almar Klein
> If the display is limited to 80 characters then after printing the 80th
> the cursor will be at the start of the next line and the newline will
> cause the display to leave a blank line (unless the display has some
> intelligence and supports pending newlines, of course).


Ahah! So Windows users should actually limit their text to 78 chars? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Almar Klein
>
> A reason not mentioned much is that some people have trouble following
> packed lines that are too much longer. Wide-page textbooks routinely put
> text in two columns for easier reading. This is less of a factor with jagged
> edge text, but if the limit were increased to say 150, there would be people
> writing multi-line 150 char wide text blocks.
>

You're right. From Lshort (the introduction to Latex): "On average, no line
should be longer than 66 characters." This applies to regular text, not for
code per see, but it makes a strong case against (very) long lines.

Almar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread John Kelly
On Tue, 17 Aug 2010 11:53:27 -0700 (PDT), Standish P 
wrote:

>Another way to pose my question, as occurred to me presently is to ask
>if a stack is a good abstraction for programming ? Certainly, it is
>the main abstraction in Forth and Postscript and implementable readily
>in C,C++ and I assume python.

>so the name of the game is the same, ie to help the programmer keep
>track of things for writing fault free code without chasing every
>case, easy visualization, easy recall and communication with fellow
>programmers of abstract concepts in terms of real world objects and
>easy modification and code reuse.


"Go is an attempt to combine the ease of programming of an interpreted,
dynamically typed language with the efficiency and safety of a
statically typed, compiled language. It also aims to be modern, with
support for networked and multicore computing"

"To make the stacks small, Go's run-time uses segmented stacks. A newly
minted goroutine is given a few kilobytes, which is almost always
enough. When it isn't, the run-time allocates (and frees) extension
segments automatically"

http://golang.org/doc/go_lang_faq.html



-- 
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opposite of split

2010-08-17 Thread News123
On 08/17/2010 05:46 PM, Grant Edwards wrote:
> On 2010-08-17, Neil Cerutti  wrote:
>> On 2010-08-17, Stefan Schwarzer  wrote:
>>> Hi Alex,
>>>
>>> On 2010-08-16 18:44, Alex van der Spek wrote:
 Anybody catches any other ways to improve my program (attached), you are 
 most welcome. Help me learn, that is one of the objectives of this 
 newsgroup, right? Or is it all about exchanging the next to impossible 
 solution to the never to happen unreal world problems?
>>>
>>> I don't know what a concordance table is, and I haven't
>>> looked a lot into your program, but anyway here are some
>>> things I noticed at a glance:
>>>
>>> | #! usr/bin/env python
>>> | # Merge log files to autolog file
>>> | import os
>>> | import fileinput
>>> | #top='C:\\Documents and Settings\\avanderspek\\My 
>>> Documents\\CiDRAdata\\Syncrude\\CSL\\August2010'
>>> | top='C:\\Users\\ZDoor\\Documents\\CiDRA\\Syncrude\CSL\\August2010'
>>>
>>> If you have backslashes in strings, you might want to use "raw
>>> strings". Instead of "c:\\Users\\ZDoor" you'd write
>>> r"c:\Users\ZDoor" (notice the r in front of the string).
>>
>> That's good general advice. But in the specific case of file
>> paths, using '/' as the separator is supported, and somewhat
>> preferable.
> 
> Unless you're going to be passing them to cmd.exe or other utilities
> via subprocess/popen.
> 
in that case you could use os.path.normpath() prior to passing it to an
external program und use slashies internally.


A little less performant, but in my opinion nicer typing.



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bash: syntax error near unexpected token

2010-08-17 Thread Hans Mulder

Benjamin Kaplan wrote:

On Mon, Aug 16, 2010 at 11:33 PM, kreglet  wrote:



desktop:~/bin$ modtest.py
desktop:~/bin$ evenodd(45)
bash: syntax error near unexpected token `45'



And this is what's supposed to happen any time you try this in any
shell. When you call evenodd, bash looks for a program or shell
built-in called evenodd. Which doesn't exist.


That's not what "syntax error means".  If the problem were that
evenodd does not exist as a shell function, the error would have
been "bash: evenodd: command not found".

I do not understand why bash says the token `45' is unexpected.
The '(' token is the problem.  It's a syntax error because in
bash syntax function arguments are not enclosed in parentheses:

$ function evenodd {
> if (( $1 % 2 ))
> then echo $1 is odd
> else echo $1 is even
> fi
> }
$ evenodd 45
45 is odd
$ evenodd(45)
bash: syntax error near unexpected token `45'
$

Of course, this is completely off-topic.

-- HansM
--
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Terry Reedy

On 8/17/2010 3:47 AM, Lawrence D'Oliveiro wrote:

In message, AK wrote:


As monitors are getting bigger, is there a general change in opinion on
the 79 chars limit in source files?


WHAT 79-character limit in source files?


Only for stdlib. Python itself has no particular limit.

The dev discussed the issue perhaps a year ago. Enough people wanted or 
needed the current stdlib limit that they decided to stick with it.


A reason not mentioned much is that some people have trouble following 
packed lines that are too much longer. Wide-page textbooks routinely put 
text in two columns for easier reading. This is less of a factor with 
jagged edge text, but if the limit were increased to say 150, there 
would be people writing multi-line 150 char wide text blocks.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread MRAB

Almar Klein wrote:



[snip]


I am in favor of the 80-char limit also. Besides the arguments listed 
above, when using an IDE it gives you that extra horizontal space to fit 
some IDE specific tools (such as source structure).


I must admit that I'm sometimes slightly frustrated when an expression 
is JUST 81 chars, and I *need* to reformat to two lines. On the other 
hand, very long lines are hard to read also. I guess the limit must be 
placed somewhere, and for historical reasons, 80 chars makes the most 
sense IMO.


On a related note, why is the limit mentioned in PEP8 79 chars, and not 
80? I never understood this :)



If the display is limited to 80 characters then after printing the 80th
the cursor will be at the start of the next line and the newline will
cause the display to leave a blank line (unless the display has some
intelligence and supports pending newlines, of course).
--
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 12:20 am, Standish P  wrote:
> [Q] How far can stack [LIFO] solve do automatic garbage collection and
> prevent memory leak ?

> Because a stack has push and pop, it is able to release and allocate
> memory. We envisage an exogenous stack which has malloc() associated
> with a push and free() associated with a pop.

> The algorithm using the stack would have to be "perfect" to prevent
> stack overflow or condition of infinite recursion depth. This would
> involve data type checking to filter out invalid input. The task must
> be casted in an algorithm that uses the stack. Then the algorithm must
> be shown to be heuristically or by its metaphor, to be correct using
> informal reasoning.

> Are there any standard textbooks or papers that show stacks
> implemented in C/C++/Python/Forth with malloc/free in push and pop ?
> If Forth is a general processing language based on stack, is it
> possible to convert any and all algorithms to stack based ones and
> thus avoid memory leaks since a pop automatically releases memory when
> free is an intrinsic part of it.

> K&R ANSI has the example of modular programming showing how to
> implement a stack but he uses a fixed length array. It is also
> possibly an endogenous stack. We look for an exogenous stack so that
> element size can vary.
>
> ===
> Standish P 

Another way to pose my question, as occurred to me presently is to ask
if a stack is a good abstraction for programming ? Certainly, it is
the main abstraction in Forth and Postscript and implementable readily
in C,C++ and I assume python.

It is true that the other languages such as F/PS also have borrowed
lists from lisp in the name of nested-dictionaries and mathematica
calls them nested-tables as its fundamental data structure.

I am asking for a characterization of algorithms that benefit from
this abstraction or programming paradigm and comparison with others.

The whole case of OOP is the clustering of thought, ie book-keeping,
in the mind of the programmer around fewer objects than ten or twenty
fold functions.

so the name of the game is the same, ie to help the programmer keep
track of things for writing fault free code without chasing every
case, easy visualization, easy recall and communication with fellow
programmers of abstract concepts in terms of real world objects and
easy modification and code reuse.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Terry Reedy

On 8/17/2010 2:26 PM, Almar Klein wrote:


On a related note, why is the limit mentioned in PEP8 79 chars, and not
80? I never understood this :)


A newline char or block or underline cursor makes 80. The importance 
depended on the terminal. 80 chars on the last line could especially be 
a problem.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Brad
On Aug 17, 10:34 am, Standish P  wrote:
> On Aug 16, 11:09 am, Elizabeth D Rather  wrote:
>
> How are these heaps being implemented ? Is there some illustrative
> code or a book showing how to implement these heaps in C for example ?
>
Forth does not use a heap, except maybe to implement malloc/free which
many Forth apps do not use. The dictionary is a linked list structure.
Now seems like a good time for you to teach yourself Forth (by
studying the best commercial implementation you can find) since you
seem to be working with a clean slate. But I will say a few things
about stacks in general.

There are many ways to implement stacks. The simplest is to declare
some space for the stack and then post-increment or pre-decrement a
stack pointer depending on whether you're pushing or popping. Normally
you make the memory for them big enough that they don't overflow.

If you are concerned about stack overflow you can change the
implementation. Add bounds checking, for example.

Another trick is to use an 8-bit stack pointer. Then you will have a
circular stack. If there is underflow or overflow it at least will not
step on other data. It will only return bad data, which you may find
preferable to an ugly crash. OTOH, bugs that cause spectacular
failures tend to be discovered. You can also initialize the stack
memory with a pattern like 0xDEAD and then after sufficiently
exercising the code, examine the memory contents to see the "high
water mark" of the stack pointer.

-Brad
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Almar Klein
On 17 August 2010 18:43, AK  wrote:

> On 08/17/2010 12:21 PM, Stefan Schwarzer wrote:
>
>> On 2010-08-17 17:44, AK wrote:
>>
>>> On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:
>>>
 I'd probably reformat this to

self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d', '%m%d%Y')

 or even

self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d',
  '%m%d%Y')

 for consistency.

 This not only limits the width but also makes the nesting of
 the calls more visible.

>>>
>>> Doesn't this create the problem of functions growing too long to fit in
>>> a screen? I think it's very useful to try to keep function size low
>>> enough so that you can view the whole function without having to scroll
>>> up and down. (even though that's not always possible) -ak
>>>
>>
>> I think I'd extract some part of the function into a new
>> function then. In my opinion, the reasoning is similar to
>> the case, "Can't I use two spaces per indentation level?
>> That way I don't run so easily into the right margin if I
>> have more than five indentations in a function." ;-)
>>
>
> I think to some extent it's a matter of taste. I bet most people would
> agree that on the balance, 2-space indentations makes code much less
> readable, despite saving a bit of space.
>
> But let me ask you, would you really prefer to have:
>
>
> self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d', '%m%d%Y')

>>>
> (or the 4-line version of this above), even when it necessitates
> creation of a new function, rather than have this code on two lines?
>
> After all, I think it's a matter of balance between readability,
> expressiveness and succinctness. If I split a function in two, that
> still means that understanding the functionality of the code will
> require scrolling around and looking at the second function. I guess
> what I'm trying to say that we shouldn't just care about readability of
> lines but also readability of functions and blocks of functionality
> (that may include several functions that accomplish a single "task".)
>
>  -andrei
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


I am in favor of the 80-char limit also. Besides the arguments listed above,
when using an IDE it gives you that extra horizontal space to fit some IDE
specific tools (such as source structure).

I must admit that I'm sometimes slightly frustrated when an expression is
JUST 81 chars, and I *need* to reformat to two lines. On the other hand,
very long lines are hard to read also. I guess the limit must be placed
somewhere, and for historical reasons, 80 chars makes the most sense IMO.

On a related note, why is the limit mentioned in PEP8 79 chars, and not 80?
I never understood this :)

Cheers,
  Almar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 17, 1:17 am, torb...@diku.dk (Torben Ægidius Mogensen) wrote:
> Standish P  writes:
> > [Q] How far can stack [LIFO] solve do automatic garbage collection and
> > prevent memory leak ?
>
> > Because a stack has push and pop, it is able to release and allocate
> > memory. We envisage an exogenous stack which has malloc() associated
> > with a push and free() associated with a pop.
>
> See

How many programmers have applied the ideas of these papers in their
programming practice ? I paste the abstract for convenience

> http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.23.5498

Abstract:
This paper describes a memory management discipline for programs that
perform dynamic memory allocation and de-allocation. At runtime, all
values are put into regions. The store consists of a stack of regions.
All points of region allocation and deallocation are inferred
automatically, using a type and effect based program analysis. The
scheme does not assume the presence of a garbage collector. The scheme
was first presented by Tofte and Talpin (1994); subsequently, it has
been tested in The ML Kit with Regions, a region-based, garbage-
collection free implementation of the Standard ML Core language, which
includes recursive datatypes, higher-order functions and updatable
references (Birkedal et al. 96, Elsman and Hallenberg 95). This paper
defines a region-based dynamic semantics for a skeletal programming
language extracted from Standard ML. We present the inference system
which specifies where regions can be allocated and de-allocated and a
detailed proof that the system is sound wi...

>
> http://portal.acm.org/citation.cfm?doid=174675.177855

ABSTRACT
We present a translation scheme for the polymorphically typed call-by-
value &lgr;-calculus. All runtime values, including function closures,
are put into regions. The store consists of a stack of regions. Region
inference and effect inference are used to infer where regions can be
allocated and de-allocated. Recursive functions are handled using a
limited form of polymorphic recursion. The translation is proved
correct with respect to a store semantics, which models as a region-
based run-time system. Experimental results suggest that regions tend
to be small, that region allocation is frequent and that overall
memory demands are usually modest, even without garbage collection.

>
> http://www.springerlink.com/content/m2074884n6gt612h/
>

Abstract
We report on our experience with designing, implementing, proving
correct, and evaluating a region-based memory management system.
dynamic storage management - regions - Standard ML



>         Torben

-- 
http://mail.python.org/mailman/listinfo/python-list


[SOLVED]: Copying a file with a question mark in it's name in Windows

2010-08-17 Thread drodrig
On Aug 12, 9:16 am, Aleksey  wrote:
> On 12 авг, 18:49,drodrig wrote:
>
> > A python script I use to backup files on a Windows 2003 server
> > occasionally fails to retrieve the size of a file with a question mark
> > in the name. The exception I get is "OSError #123 The filename,
> > directory name, or volume label syntax is incorrect". I realize that
> > technically a question mark in the name of a file on Windows is
> > illegal, but nevertheless these files exist on the file system. It
> > seems that they are created by Office 2007 Word, for the most part.
(Sorry for the late reply)

Thank you. The questions marks are indeed placeholders for unprintable
characters. The glob module did the trick.

>
> If "?" is a placeholder for an unprintable character you can try view
> real file name in IDLE:
>
>   import glob
>   print glob.glob(u'e:/full/path/to/file?')
>
> In path to file you must instead question use wild "?".
> Will be printed all like files.
>
> -
> Under Windows I too have similar problem: windows sometimes (from any
> programs - e.g. Firefox) save files with wrong names, but later
> do not manipulate with it.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread James Kanze
On Aug 17, 6:21 pm, Standish P  wrote:
> > Garbage collection doesn't use a stack. It uses a "heap",
> > which is in the abstract a collection of memory blocks of
> > different lengths, divided into two lists, generally
> > represented as linked lists:

> > 1.  A list of blocks that are free and may be used to store
> > new data

> > 2.  A list of blocks that are in use, or haven't been freed (yet)

> Is this all that a heap is or is there more to it ?

There are many different ways to implement a heap.  The above is
not a good one, and I doubt that it's really used anywhere.

> I have been looking for simple but complete explanation of
> heap for a while and not gotten to it.

Complete in what sense?  The basic principle of how to use it is
simple.  As for how to implement it, there are many different
algorithms that can be used.

> I think I am looking for a stack allocation on the same
> pattern.

Stack allocation is far, far simpler (usually).

> In a disk, a file is fragmented in many contiguous blocks and
> is accessed automatically.

At the system level, the same thing holds for memory, and the
actual physical memory is "fragmented" into contiguous blocks,
each the size of a page.  The MMU (hardware) makes this
transparent to user programs, however.

> > There is no way you could do memory management of all but the most
> > trivial and fixed-length data chunks using a stack.

The length isn't the issue.  The order of allocation and freeing
is.  (For many specific uses, stack based allocators can and
have been used, but they don't work for generally allocation.)

--
James Kanze
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Martin Gregorie
On Tue, 17 Aug 2010 10:22:27 -0500, Robert Kern wrote:

> On 8/16/10 11:10 PM, Steven D'Aprano wrote:
>> On Mon, 16 Aug 2010 22:56:20 -0500, Robert Kern wrote:
>>
>>> On 8/16/10 9:29 PM, Roy Smith wrote:
 In article,
Lawrence D'Oliveiro   wrote:

> In message, Roy Smith
> wrote:
>
>> 5) real intensity[160.0 : 30.0 : 0.01]
>
> How many elements in that array?
>
> a) 2999
> b) 3000
> c) neither of the above

 c) neither of the above.  More specifically, 13,001 (if I counted
 correctly).
>>>
>>> 13000, actually. Floating point is a bitch.
>>>
>>> [~/Movies]
>>> |1>  import numpy
>>>
>>> [~/Movies]
>>> |2>  len(numpy.r_[160.0:30.0:-0.01])
>>> 13000
>>
>>
>> Actually, the answer is 0, not 13000, because the step size is given as
>> 0.01, not -0.01.
>>
> import numpy
> len(numpy.r_[160.0:30.0:-0.01])
>> 13000
> len(numpy.r_[160.0:30.0:0.01])
>> 0
> 
> Roy wasn't using numpy/Python semantics but made-up semantics (following
> Martin Gregorie's made-up semantics to which he was replying) which
> treat the step size as a true size, not a size and direction. The
> direction is determined from the start and stop parameters. It's an
> almost-reasonable design.

That wasn't a made-up example: AFAICR and ignoring a missing semi-colon 
it was an Algol 68 snippet. The semantics of the for statement and the 
use of lwb and upb operators to extract the bounds from a 1-dimensional 
array are correct A68, but OTOH its a very long time since I last 
programmed in that language. I used that rather than Python because Algol 
68 supports the non-zero lower bound and treats the array limits as 
attributes of the array.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 11:09 am, Elizabeth D Rather  wrote:
> On 8/15/10 10:33 PM, Standish P wrote:

>
> >>> If Forth is a general processing language based on stack, is it
> >>> possible to convert any and all algorithms to stack based ones and
> >>> thus avoid memory leaks since a pop automatically releases memory when
> >>> free is an intrinsic part of it.
>
> Forth uses two stacks.  The "data stack" is used for passing parameters
> between subroutines ("words") and is completely under the control of the
> programmer.  Words expect parameters on this stack; they remove them,
> and leave only explicit results.  The "return stack" is used primarily
> for return addresses when words are called, although it is also
> available for auxiliary uses under guidelines which respect the primary
> use for return addresses.
>
> Although implementations vary, in most Forths stacks grow from a fixed
> point (one for each stack) into otherwise-unused memory.  The space
> involved is allocated when the program is launched, and is not managed
> as a heap and allocated or deallocated by any complicated mechanism.  On
> multitasking Forth systems, each task has its own stacks.  Where
> floating point is implemented (Forth's native arithmetic is
> integer-based), there is usually a separate stack for floats, to take
> advantage of hardware FP stacks.
>
> >>     - is forth a general purpose language? Yes
> >>     - are all algorithms stack based? No
>
> > Does Forth uses stack for all algorithms ? Does it use pointers , ie
> > indirect addressing ? If it can/must use stack then every algorithm
> > could be made stack based.
>
> Forth uses its data stack for parameter passing and storage of temporary
> values.  It is also possible to define variables, strings, and arrays in
> memory, in which case their addresses may be passed on the data stack.
>
> Forth is architecturally very simple.  Memory allocations for variables,
> etc., are normally static, although some implementations include
> facilities for heaps as needed by applications.

> although some implementations include facilities for heaps as needed by 
> applications.

How are these heaps being implemented ? Is there some illustrative
code or a book showing how to implement these heaps in C for example ?

Are dictionaries of forth and postscript themselves stacks if we
consider them as nested two column tables which lisp's lists are in
essence, but only single row. Multiple rows would just be multiple
instances of it at the same level inside parens.

we can peek into stacks which is like car. if it is not unusually
costly computation, why not allow it ? there is no need to restrict to
push and pop.

roll( stack_name, num)

itself can give all those postfix permutations that push and pop cant
generate with a single stack. Can we use dictionaries to generate
multiple stacks inside one global stack ?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P

> Garbage collection doesn't use a stack. It uses a "heap", which is in
> the abstract a collection of memory blocks of different lengths,
> divided into two lists, generally represented as linked lists:
>
> 1.  A list of blocks that are free and may be used to store new data
>
> 2.  A list of blocks that are in use, or haven't been freed (yet)

Is this all that a heap is or is there more to it ? I have been
looking for simple but complete explanation of heap for a while and
not gotten to it. I think I am looking for a stack allocation on the
same pattern. In a disk, a file is fragmented in many contiguous
blocks and is accessed automatically.

> There is no way you could do memory management of all but the most
> trivial and fixed-length data chunks using a stack. Sure, you could
> reserve thousands of bytes on the stack for an array but suppose your
> language allows arrays to grow or shrink. To keep its property of
> being adjacent, you'd have to do something horrible such as move
> unrelated data allocated later, which raises all sorts of security
> issues, doesn't it.


> A stack, or something which works like a stack (that is, a stack) is a
> necessary but not sufficient condition for a working C runtime because
> C functions can call themselves recursively, whether directly or
> indirectly. If this last condition did not obtain, each function could
> give the functions it calls some of its own memory and the called
> function could save a fixed set of non-stacked general registers in
> that area; this was in fact the practice on IBM 370 and in assembler
> language at a time when many "data processing managers" though
> recursion was a Communist plot.
>
> However, data structures of variable size, or data structures that
> merely take up a lot of space, don't play nice with others on the
> stack, so, we place their address on the stack and store them in
> another place, which was named the heap, probably, as a sort of
> witticism.
>
> Gilbert and Sullivan:
>
> If anyone anything lacks
> He'll find it all ready in stacks

This you might want to take this to the Forth people because they are
marketing their language as a cure for all that plagues programming
today.

> was wrong, and needs to be brought up to date:
>
> You cannot do everything in a stack
> Unless you code an almighty hack
> If you're a coding Knight who says, "Neep",
> You'll probably need to implement a heap
> A pile a heap of benefits you'll reap
> If only my advice in your brain you'll keep
> And avoid memory leaks from which data doth seep
> By using a well-implemented, well structured, and well-documented
> Heap!
>
> [Chorus of Sailors]
> We will to heart your advice take, and always use a heap!
>
> [Soloist]
> Oh thank you do
> To this be true
> And always my sage advice do keep
> That you always need to use a heap!- Hide quoted text -
>
> - Show quoted text -

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing variables as object attributes

2010-08-17 Thread Vikas Mahajan
I got the concept to get and set object attributes and now can handle
similar problems effectively.

Thanks to all for your help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How far can stack [LIFO] solve do automatic garbage collection and prevent memory leak ?

2010-08-17 Thread Standish P
On Aug 16, 4:20 am, Malcolm McLean 
wrote:
> On Aug 16, 10:20 am, Standish P  wrote:> [Q] How far can 
> stack [LIFO] solve do automatic garbage collection and
> > prevent memory leak ?
>
> Most programs can be written so that most of their memory allocations
> are matched by destructors at the same level.
>
> However the allocations that can't be written this way typically tend
> to be the small frequently-called ones used for nodes in dynamic graph
> objects, or small resizeable buffers to hold strings and the like.
> This is where you get the performance hit with repeated calls to
> malloc() and free().
>
> So generally it's not worthwhile writing a stack allocator for a
> normal program. That's not to say there aren't a few individual cases
> where it can help performance. (See the chapter "Memory games" in my
> book Basic Agorithms for details about memory allocation strategies).

all the page numbers in your books TOC have a little varying offset
from actual, pictures are nice for kids ..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Neil Cerutti
On 2010-08-17, AK  wrote:
> After all, I think it's a matter of balance between
> readability, expressiveness and succinctness. If I split a
> function in two, that still means that understanding the
> functionality of the code will require scrolling around and
> looking at the second function. I guess what I'm trying to say
> that we shouldn't just care about readability of lines but also
> readability of functions and blocks of functionality (that may
> include several functions that accomplish a single "task".)

When considering creating variables and functions, I try to use
the same rule of thumb: If I can come up with a good name for it
relatively quickly, then it probably deserves to exist. If all I
can think of is 'func' or 'x', then it's an artifact that I hope
to avoid.

Splitting a function in two need not obscure the meaning, and may
even improve it, *if* the names of the new functions are good.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread AK

On 08/17/2010 12:21 PM, Stefan Schwarzer wrote:

On 2010-08-17 17:44, AK wrote:

On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:

I'd probably reformat this to

self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d', '%m%d%Y')

or even

self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d',
  '%m%d%Y')

for consistency.

This not only limits the width but also makes the nesting of
the calls more visible.


Doesn't this create the problem of functions growing too long to fit in
a screen? I think it's very useful to try to keep function size low
enough so that you can view the whole function without having to scroll
up and down. (even though that's not always possible) -ak


I think I'd extract some part of the function into a new
function then. In my opinion, the reasoning is similar to
the case, "Can't I use two spaces per indentation level?
That way I don't run so easily into the right margin if I
have more than five indentations in a function." ;-)


I think to some extent it's a matter of taste. I bet most people would
agree that on the balance, 2-space indentations makes code much less
readable, despite saving a bit of space.

But let me ask you, would you really prefer to have:


self.expiration_date = translate_date(
  find(response, 'MPNExpirationDate').text,
  '%Y-%m-%d', '%m%d%Y')


(or the 4-line version of this above), even when it necessitates
creation of a new function, rather than have this code on two lines?

After all, I think it's a matter of balance between readability,
expressiveness and succinctness. If I split a function in two, that
still means that understanding the functionality of the code will
require scrolling around and looking at the second function. I guess
what I'm trying to say that we shouldn't just care about readability of
lines but also readability of functions and blocks of functionality
(that may include several functions that accomplish a single "task".)

 -andrei
--
http://mail.python.org/mailman/listinfo/python-list


Open a command pipe for reading

2010-08-17 Thread Rodrick Brown
I have a fairly large file 1-2GB in size that I need to process line by line 
but I first need to convert the file to text using a 3rd party tool that prints 
the records also line by line.

I've tried using Popen to do this with no luck. I'm trying to simulate 

/bin/foo myfile.dat 

And as the records are being printed do some calculations. 

pipe = Popen(exttool,shell=True,stdout=PIPE).stdout 

for data in pipe.readlines():
print data,

This operation blocks forever I'm guessing it's trying to process the entire 
file at once. 

Sent from my iPhone 4.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Stefan Schwarzer
On 2010-08-17 17:44, AK wrote:
> On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:
>> I'd probably reformat this to
>>
>>self.expiration_date = translate_date(
>>  find(response, 'MPNExpirationDate').text,
>>  '%Y-%m-%d', '%m%d%Y')
>>
>> or even
>>
>>self.expiration_date = translate_date(
>>  find(response, 'MPNExpirationDate').text,
>>  '%Y-%m-%d',
>>  '%m%d%Y')
>>
>> for consistency.
>>
>> This not only limits the width but also makes the nesting of
>> the calls more visible.
> 
> Doesn't this create the problem of functions growing too long to fit in
> a screen? I think it's very useful to try to keep function size low
> enough so that you can view the whole function without having to scroll
> up and down. (even though that's not always possible) -ak

I think I'd extract some part of the function into a new
function then. In my opinion, the reasoning is similar to
the case, "Can't I use two spaces per indentation level?
That way I don't run so easily into the right margin if I
have more than five indentations in a function." ;-)

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Developer - HFT Trading firm - Chicago, IL

2010-08-17 Thread Rich Moss

Python developer needed for math/trading applications and research at
leading HFT firm. The person we are searching for will have a strong
background with python programming and the ability to work with very
large historical datasets. You should have a very strong math
background as well. This can involve writing very complicated python
scripts and programs! You will work very closely with traders and
quantitative analysts in their equities trading group on state-of-the-
art trading strategy and execution systems.

Requires:

Strong python programming experience developing applications and
scripts using complex regular expressions

Strong math knowledge and education
Experience working with massive datatsets/historical data

This company is a top-tier electronic, algorithmic trading firm,
located in Chicago, IL. This firm is one of the most advanced high
frequency electronic trading firms in the world and uses python
throughout the company, as well as other languages. This firm has a
culture that rewards creativity and hard work. No third parties,
please. We will not consider candidates from outside the USA. No
telecommuting. We offer very generous compensation (best in the
industry), fantastic benefits and very generous relocation packages.
Please contact me immediately with a resume!

Send resumes to:

Rich Moss
r...@mossltd.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opposite of split

2010-08-17 Thread Grant Edwards
On 2010-08-17, Neil Cerutti  wrote:
> On 2010-08-17, Stefan Schwarzer  wrote:
>> Hi Alex,
>>
>> On 2010-08-16 18:44, Alex van der Spek wrote:
>>> Anybody catches any other ways to improve my program (attached), you are 
>>> most welcome. Help me learn, that is one of the objectives of this 
>>> newsgroup, right? Or is it all about exchanging the next to impossible 
>>> solution to the never to happen unreal world problems?
>>
>> I don't know what a concordance table is, and I haven't
>> looked a lot into your program, but anyway here are some
>> things I noticed at a glance:
>>
>>| #! usr/bin/env python
>>| # Merge log files to autolog file
>>| import os
>>| import fileinput
>>| #top='C:\\Documents and Settings\\avanderspek\\My 
>>Documents\\CiDRAdata\\Syncrude\\CSL\\August2010'
>>| top='C:\\Users\\ZDoor\\Documents\\CiDRA\\Syncrude\CSL\\August2010'
>>
>> If you have backslashes in strings, you might want to use "raw
>> strings". Instead of "c:\\Users\\ZDoor" you'd write
>> r"c:\Users\ZDoor" (notice the r in front of the string).
>
> That's good general advice. But in the specific case of file
> paths, using '/' as the separator is supported, and somewhat
> preferable.

Unless you're going to be passing them to cmd.exe or other utilities
via subprocess/popen.

-- 
Grant Edwards   grant.b.edwardsYow! MY income is ALL
  at   disposable!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EOFError with fileinput

2010-08-17 Thread Alex van der Spek
Thanks all! I understand better now. I had no idea that EOFError was an 
exception. I was looking for a function to tell me when the end of a 
sequential file is reached as in all of the 4 programming languages that I 
do know this is a requirement.


Will modify my program accordingly.

Alex van der Spek 


--
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread D'Arcy J.M. Cain
On Tue, 17 Aug 2010 16:28:02 +0200
Stefan Schwarzer  wrote:
> I'd probably reformat this to
> 
>   self.expiration_date = translate_date(
> find(response, 'MPNExpirationDate').text,
> '%Y-%m-%d', '%m%d%Y')
> 
> or even
> 
>   self.expiration_date = translate_date(
> find(response, 'MPNExpirationDate').text,
> '%Y-%m-%d',
> '%m%d%Y')

You can extend this if there are complicated sub-calls.  Probably
overkill for this example but here is the idea.

   self.expiration_date = translate_date(
 find(
   response,
  'MPNExpirationDate',
 ).text,
 '%Y-%m-%d',
 '%m%d%Y'
   )

I also moved the closing brace down to align with the line that opened
that block.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread AK

On 08/17/2010 10:28 AM, Stefan Schwarzer wrote:

Hi Neil,

On 2010-08-17 14:42, Neil Cerutti wrote:

On 2010-08-17, Michael Torrie  wrote:

In general if I find myself consistently going longer than 75
or 80 characters, I need to refactor my code to make it more
manageable.  If I have to scroll up five pages to find the
beginning of a block, that normally means my code could be
simplified and improved.


Looking through my code, the split-up lines almost always include
string literals or elimination of meaningless temporary
variables, e.g.:

 self.expiration_date = translate_date(find(response,
 'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y')


I'd probably reformat this to

   self.expiration_date = translate_date(
 find(response, 'MPNExpirationDate').text,
 '%Y-%m-%d', '%m%d%Y')

or even

   self.expiration_date = translate_date(
 find(response, 'MPNExpirationDate').text,
 '%Y-%m-%d',
 '%m%d%Y')

for consistency.

This not only limits the width but also makes the nesting of
the calls more visible.

Stefan


Doesn't this create the problem of functions growing too long to fit in
a screen? I think it's very useful to try to keep function size low
enough so that you can view the whole function without having to scroll
up and down. (even though that's not always possible) -ak
--
http://mail.python.org/mailman/listinfo/python-list


Re: Opposite of split

2010-08-17 Thread Neil Cerutti
On 2010-08-17, Stefan Schwarzer  wrote:
> Hi Alex,
>
> On 2010-08-16 18:44, Alex van der Spek wrote:
>> Anybody catches any other ways to improve my program (attached), you are 
>> most welcome. Help me learn, that is one of the objectives of this 
>> newsgroup, right? Or is it all about exchanging the next to impossible 
>> solution to the never to happen unreal world problems?
>
> I don't know what a concordance table is, and I haven't
> looked a lot into your program, but anyway here are some
> things I noticed at a glance:
>
>| #! usr/bin/env python
>| # Merge log files to autolog file
>| import os
>| import fileinput
>| #top='C:\\Documents and Settings\\avanderspek\\My 
>Documents\\CiDRAdata\\Syncrude\\CSL\\August2010'
>| top='C:\\Users\\ZDoor\\Documents\\CiDRA\\Syncrude\CSL\\August2010'
>
> If you have backslashes in strings, you might want to use "raw
> strings". Instead of "c:\\Users\\ZDoor" you'd write
> r"c:\Users\ZDoor" (notice the r in front of the string).

That's good general advice. But in the specific case of file
paths, using '/' as the separator is supported, and somewhat
preferable.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Neil Cerutti
On 2010-08-17, Stefan Schwarzer  wrote:
> Hi Neil,
>
> On 2010-08-17 14:42, Neil Cerutti wrote:
>> Looking through my code, the split-up lines almost always
>> include string literals or elimination of meaningless
>> temporary variables, e.g.:
>> 
>> self.expiration_date = translate_date(find(response,
>> 'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y')
>
> I'd probably reformat this to
>
>   self.expiration_date = translate_date(
> find(response, 'MPNExpirationDate').text,
> '%Y-%m-%d', '%m%d%Y')
>
> or even
>
>   self.expiration_date = translate_date(
> find(response, 'MPNExpirationDate').text,
> '%Y-%m-%d',
> '%m%d%Y')
>
> for consistency.
>
> This not only limits the width but also makes the nesting of
> the calls more visible.

Those are nice improvements. Thanks!

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Robert Kern

On 8/16/10 11:10 PM, Steven D'Aprano wrote:

On Mon, 16 Aug 2010 22:56:20 -0500, Robert Kern wrote:


On 8/16/10 9:29 PM, Roy Smith wrote:

In article,
   Lawrence D'Oliveiro   wrote:


In message, Roy Smith wrote:


5) real intensity[160.0 : 30.0 : 0.01]


How many elements in that array?

a) 2999
b) 3000
c) neither of the above


c) neither of the above.  More specifically, 13,001 (if I counted
correctly).


13000, actually. Floating point is a bitch.

[~/Movies]
|1>  import numpy

[~/Movies]
|2>  len(numpy.r_[160.0:30.0:-0.01])
13000



Actually, the answer is 0, not 13000, because the step size is given as
0.01, not -0.01.


import numpy
len(numpy.r_[160.0:30.0:-0.01])

13000

len(numpy.r_[160.0:30.0:0.01])

0


Roy wasn't using numpy/Python semantics but made-up semantics (following Martin 
Gregorie's made-up semantics to which he was replying) which treat the step size 
as a true size, not a size and direction. The direction is determined from the 
start and stop parameters. It's an almost-reasonable design.


--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
http://mail.python.org/mailman/listinfo/python-list


Podcast about Python's versions and implementations

2010-08-17 Thread Ron
New podcast up is a look at the various versions and implementations
of Python, including Python 3, Python 2, PyPy, IronPython, Jython,
Stackless, Psycho, Shedskin, Cython, Unladen Swallow, Berp, etc.

http://www.awaretek.com/python/

Ron
-- 
http://mail.python.org/mailman/listinfo/python-list


scrapelib for web scraping

2010-08-17 Thread Ron
Shameless plug for a web scraping tool my son is involved in creating,
called scrapelib. He is on leave from university and is a consultant
for the Sunlight Foundation creating something called the Fifty States
Project to monitor lobbyist money to state governments in the USA.

http://github.com/mikejs/scrapelib
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Stefan Schwarzer
Hi Neil,

On 2010-08-17 14:42, Neil Cerutti wrote:
> On 2010-08-17, Michael Torrie  wrote:
>> In general if I find myself consistently going longer than 75
>> or 80 characters, I need to refactor my code to make it more
>> manageable.  If I have to scroll up five pages to find the
>> beginning of a block, that normally means my code could be
>> simplified and improved.
> 
> Looking through my code, the split-up lines almost always include
> string literals or elimination of meaningless temporary
> variables, e.g.:
> 
> self.expiration_date = translate_date(find(response,
> 'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y')

I'd probably reformat this to

  self.expiration_date = translate_date(
find(response, 'MPNExpirationDate').text,
'%Y-%m-%d', '%m%d%Y')

or even

  self.expiration_date = translate_date(
find(response, 'MPNExpirationDate').text,
'%Y-%m-%d',
'%m%d%Y')

for consistency.

This not only limits the width but also makes the nesting of
the calls more visible.

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Python for MultiTouch!

2010-08-17 Thread Ron
Along with the news of Unbuntu supporting multitouch, I saw this and
just had to share, I think its really nice: PyMT

http://the-space-station.com/2010/8/16/python-multitouch:-pymt-0-5-released
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opposite of split

2010-08-17 Thread Stefan Schwarzer
Hi Alex,

On 2010-08-16 18:44, Alex van der Spek wrote:
> Anybody catches any other ways to improve my program (attached), you are 
> most welcome. Help me learn, that is one of the objectives of this 
> newsgroup, right? Or is it all about exchanging the next to impossible 
> solution to the never to happen unreal world problems?

I don't know what a concordance table is, and I haven't
looked a lot into your program, but anyway here are some
things I noticed at a glance:

| #! usr/bin/env python
| # Merge log files to autolog file
| import os
| import fileinput
| #top='C:\\Documents and Settings\\avanderspek\\My 
Documents\\CiDRAdata\\Syncrude\\CSL\\August2010'
| top='C:\\Users\\ZDoor\\Documents\\CiDRA\\Syncrude\CSL\\August2010'

If you have backslashes in strings, you might want to use
"raw strings". Instead of "c:\\Users\\ZDoor" you'd write
r"c:\Users\ZDoor" (notice the r in front of the string).

| i,j,k=0,0,0
| date={}

I suggest to use more spacing to make the code more
readable. Have a look at

http://www.python.org/dev/peps/pep-0008/

for more formatting (and other) tips.

| fps=0.3048
| tab='\t'
|
| bt='-999.25'+'\t''-999.25'+'\t''-999.25'+'\t''-999.25'+'\t'+'-999.25'

If these numbers are always the same, you should use
something like

NUMBER = "-999.25"
COLUMNS = 5
bt = "\t".join(COLUMNS * [NUMBER])

(with better naming, of course).

Why don't you use `tab` here?

I _highly_ recommend to use longer (unabbreviated) names.

| al='Status'+'\t'+'State'+'\t'+'-999.25'
|
| for root,dirs,files in os.walk(top):
| #Build a concordance table of days on which data was collected
| for name in files:
| ext=name.split('.',1)[1]

There's a function `splitext` in `os.path`.

| if ext=='txt':
| dat=name.split('_')[1].split('y')[1]
| if dat in date.keys():

You can just write `if dat in date` (in Python versions >=
2.2, I think).

| date[dat]+=1
| else:
| date[dat]=1
| print 'Concordance table of days:'
| print date
| print 'List of files processed:'
| #Build a list of same day filenames, 5 max for a profile meter,skip first 
and last days
| for f in sorted(date.keys())[2:-1]:
| logs=[]
| for name in files:
| ext=name.split('.')[1]
| if ext=='txt':
| dat=name.split('_')[1].split('y')[1]

I guess I'd move the parsing stuff (`x.split(s)[i]` etc.)
into small functions with meaningful names. After that I'd
probably notice there's much redundancy and refactor them. ;)

| if dat==f:
| logs.append(os.path.join(root,name))
| #Open the files and read line by line
| datsec=False
| lines=[[] for i in range(5)]

One thing to watch out for: The above is different from
`[[]] * 5` which uses the _same_ empty list for all entries.
Probably the semantics you chose is correct.

| fn=0
| for line in fileinput.input(logs):
| if line.split()[0]=='DataID':
| datsec=True
| ln=0
| if datsec:
| lines[fn].append(line.split())
| ln+=1
| if ln==10255:

This looks like a "magic number" and should be turned into a
constant.

| datsec=False
| fileinput.nextfile()
| fn+=1
| print fileinput.filename().rsplit('\\',1)[1]
| fileinput.close()
| aut='000_AutoLog'+f+'.log'
| out=os.path.join(root,aut)
| alf=open(out,'w')
| alf.write('Timestamp (mm/dd/ hh:mm:ss)VF 1VF 2VF 3
VF 4VF 5Q 1 Q 2 Q 3 Q 4 Q 5 Status  State   Metric  
Band Temperature 1  Band Temperature 2  Band Temperature 3  Band 
Temperature 4  Band Temperature 5  SPL 1   SPL 2   SPL 3   SPL 4   SPL 
5'+'\n')
| for wn in range(1,10255,1):

You don't need to write the step argument if it's 1.

| for i in range(5):
| lines[i][wn][2]=str(float(lines[i][wn][2])/fps)
| tp=lines[0][wn][0]+' '+lines[0][wn][1]
| vf=tab.join([lines[i][wn][2] for i in range(5)])
| vq=tab.join([lines[i][wn][3] for i in range(5)])
| vs=tab.join([lines[i][wn][4] for i in range(5)])
| #sf=tab.join([lines[i][wn][5] for i in range(5)])
| #sq=tab.join([lines[i][wn][6] for i in range(5)])
| #ss=tab.join([lines[i][wn][7] for i in range(5)])

Maybe use an extra function?

def choose_a_better_name():
return tab.join([lines[index][wn][2] for index in range(5)])

Moreover, the repetition of this line looks as if you wanted
to put the right hand sides of the assignments in a list,
instead of assigning to distinct names (`vf` etc.).

By the way, you use the number 5 a lot. I guess this should
be a constant, too.

| alf.write(tp+'\t'+vf+'\t'+vq+'\t'+al+'\t'+bt+'\t'+vs+'\n')

Re: 79 chars or more?

2010-08-17 Thread Martin Gregorie
On Tue, 17 Aug 2010 13:00:51 +1000, James Mills wrote:

> Roy, under normal circumstances I would agree with you and have a
> different opinion. However being vision impaired restricts the available
> width (irregardless of the width of the monitor) of text I'm able to
> view at once.
>
I'm with James here because:
1) ssh terminal windows generally come up as 24 x 80
2) at 24 x 80 I can get more ssh terminal windows on the desktop with
   minimal overlap than I can do with longer/wider windows.

BTW, James, would it be a bore to add a space after the two hyphens at 
the top of your sig, i.e. use "-- ", not "--"? That way most news readers 
will automatically remove your sig when replying to your post.
 

-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python "why" questions

2010-08-17 Thread Lie Ryan
On 08/16/10 21:54, David Cournapeau wrote:
> On Mon, Aug 16, 2010 at 9:53 AM, Gregory Ewing
>  wrote:
>>> On Aug 7, 2010, at 9:14 PM, John Nagle wrote:
>>>
  The languages which have real multidimensional arrays, rather
 than arrays of arrays, tend to use 1-based subscripts.  That
 reflects standard practice in mathematics.
>>
>> Not always -- mathematicians use whatever starting index is
>> most convenient for the problem at hand.
> 
> Yes, there are many engineering fields where index starts at 0. Partly
> for the reason you have stated concerning polynomials, especially
> since this extend to series, which are pervasive in numerical
> computing. In linear algebra, though, I remember to have always noted
> matrices indexes in the [1,n] range, not [0,n-1].

I'm sure some would prefer to denote it as [0, n)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Roy Smith
In article ,
 Lawrence D'Oliveiro  wrote:

> In message , AK wrote:
> 
> > As monitors are getting bigger, is there a general change in opinion on
> > the 79 chars limit in source files?
> 
> WHAT 79-character limit in source files?
> 
> I currently have my Emacs windows set at 100 characters wide, and I’m 
> thinking of going wider.
> 
> Remember, the old hardcopy terminals used to produce 132-character-wide 
> listings.

Those of you who think "old hardcopy terminals" did 132 wide obviously 
don't remember the ASR-33 :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Neil Cerutti
On 2010-08-17, Michael Torrie  wrote:
> In general if I find myself consistently going longer than 75
> or 80 characters, I need to refactor my code to make it more
> manageable.  If I have to scroll up five pages to find the
> beginning of a block, that normally means my code could be
> simplified and improved.

Looking through my code, the split-up lines almost always include
string literals or elimination of meaningless temporary
variables, e.g.:

self.expiration_date = translate_date(find(response,
'MPNExpirationDate').text, '%Y-%m-%d', '%m%d%Y')

The other cases are when indentation levels get the best of me,
but I'm too lazy to refactor.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: update of elements in GUI

2010-08-17 Thread Eric Brunel
(Top-post corrected; please don't do that, it makes messages very hard 
to read via usenetŠ)

In article 
<26c363c8-11d7-49b9-a1c1-251ab5ff9...@p22g2000pre.googlegroups.com>,
 Jah_Alarm  wrote:
> On Aug 17, 7:19 pm, Eric Brunel 
> wrote:
> > You have to call update_idletasks on a Tkinter *widget*, not a variable.
> > You can call it on your window (Tk or Toplevel instance) or on your
> > label for example. This way, it should work.
> >
> thanks. The thing is, the objects actually get updated without this
> command, but when I run the GUI outside of python shell (i.e. in
> command prompt as python filename.py or compile it to .exe file) the
> objects do not get updated. I tried
> Label(mainframe,textvariable=var).grid(column=1,row=1).update_idletasks()
> and mainframe.update_idletasks() but it still doesn't work.

I think you're really misunderstanding something here: the call to 
update_idletasks is a one shot call to the GUI to basically tell it to 
refresh itself. So each time you change anything that should be 
displayed, you have to call that method again, or your changes will only 
be seen when the control returns to the GUI, which is basically at the 
end of your processing.

The fact that it works when you're doing it interactively is normal. In 
this mode, you don't have a GUI event loop running, so the GUI updates 
itself all the time automatically. This is never true in programs you 
run the 'normal' way, i.e via: python filename.py

And by the way, Label(Š).grid(Š).update_idletasks() had no chance to 
work anyway: the grid method doesn't return anything, so you're trying 
to call the update_idletasks method on None hereŠ

HTH
 - Eric -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: update of elements in GUI

2010-08-17 Thread Jah_Alarm
In MATLAB this command is drawnow, just in case

On Aug 17, 9:49 pm, Jah_Alarm  wrote:
> thanks. The thing is, the objects actually get updated without this
> command, but when I run the GUI outside of python shell (i.e. in
> command prompt as python filename.py or compile it to .exe file) the
> objects do not get updated. I tried
> Label(mainframe,textvariable=var).grid(column=1,row=1).update_idletasks()
> and mainframe.update_idletasks() but it still doesn't work.
>
> On Aug 17, 7:19 pm, Eric Brunel 
> wrote:
>
>
>
> > In article
> > <24dc97b3-a8b5-4638-9cf5-a397f1eae...@q16g2000prf.googlegroups.com>,
>
> >  Jah_Alarm  wrote:
> > > hi, I've already asked this question but so far the progress has been
> > > small.
>
> > > I'm running Tkinter. I have some elements on the screen (Labels, most
> > > importantly) which content has to be updated every iteration of the
> > > algorithm run, e.g. "Iteration =" [i] for i in range(n), n=100. I'm
> > > using the update_idletasks() command in the function itself after the
> > > variable.set(...) command. The variable type is IntVar(), and the
> > > mistake I'm getting is 'IntVar instance has no attribute
> > > 'update_idletasks'. No updates are displayed, of course.
>
> > You have to call update_idletasks on a Tkinter *widget*, not a variable.
> > You can call it on your window (Tk or Toplevel instance) or on your
> > label for example. This way, it should work.
>
> > > Without the GUI the algorithm (it's a genetic algorithm) is working
> > > fine, but I need to make it available to other people via GUI
>
> > > cheers,
>
> > > Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: message box in Tkinter

2010-08-17 Thread Eric Brunel
In article 
<61cbd1cb-bd6d-49aa-818f-d28c46098...@x18g2000pro.googlegroups.com>,
 Jah_Alarm  wrote:

> I need to display a message box at the click of a button. I od the
> following:
> 
> from Tkinter import *
> 
> def msg1():
> messagebox.showinfo(message='Have a good day')
> 
> 
> Button(mainframe,text="About",command=msg1()).grid(column=360,row=36,sticky=W)
> 
> I get the error msg 'global name 'messagebox' is not defined'
> 
> When I try importing messagebox from Tkinter i get an error message
> that this module doesn't exist.
> 
> thanks

Where did you find any reference to something called messagebox? The 
actual module name is tkMessageBox and it should be imported separately:

import tkMessageBox
tkMessageBox.showinfo(message='Have a good day')

Should work that way.
HTH
 - Eric -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: message box in Tkinter

2010-08-17 Thread Matt Saxton
On Tue, 17 Aug 2010 04:02:23 -0700 (PDT)
Jah_Alarm  wrote:

> 
> When I try importing messagebox from Tkinter i get an error message
> that this module doesn't exist.
> 

I believe what you want is Tkinter.Message


-- 
Matt Saxton 
-- 
http://mail.python.org/mailman/listinfo/python-list


message box in Tkinter

2010-08-17 Thread Jah_Alarm
I need to display a message box at the click of a button. I od the
following:

from Tkinter import *

def msg1():
messagebox.showinfo(message='Have a good day')


Button(mainframe,text="About",command=msg1()).grid(column=360,row=36,sticky=W)

I get the error msg 'global name 'messagebox' is not defined'

When I try importing messagebox from Tkinter i get an error message
that this module doesn't exist.

thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread BartC



"James Mills"  wrote in message 
news:mailman..1282019212.1673.python-l...@python.org...

On Tue, Aug 17, 2010 at 2:12 PM, AK  wrote:

There's no doubt that there are pro's and con's, but to be fair, it's
not like code becomes unreadable over 79 chars - the difference is that
when your terminal is 80 chars, it's less convenient for you to read
code that's wider and when your terminal is wider, it's less convenient
to read code that's 79 chars.


I guess there are two-sides to the coin here so to speak. See I'm
vision impaired
so I prefer a 79 char width in my own projects


That's not a good argument for everyone else to do the same. Someone else 
might prefer 40 columns for similar reasons.


(Anyway can't a 100-column width be squeezed into the same angular field as 
80-columns, just by using a narrower font, when necessary? Assuming the 
problem is field width rather than acuity)



The other side is this... I'm of the opinion that if you're writing a
line of code
that's excessively long (>80char or say >100chars), then you might want to
reconsider what you're doing :) (It might be wrong).


I generally use 100 columns. It's useful for being able to write same-line 
comments with meaningful content...


(I've used 80-column hardware (teletypes and such) years ago, I thought such 
restrictions had vanished long ago)


--
Bartc 


--
http://mail.python.org/mailman/listinfo/python-list


Re: passing variables as object attributes

2010-08-17 Thread Bruno Desthuilliers

Vikas Mahajan a écrit :

On 16 August 2010 19:23, Nitin Pawar  wrote:

you would need to define a class first with its attiributes and then you may
want to initiate the variables by calling the class initilializer


Actually I have to dynamically add attributes to a object. I am
writing python script for  FreeCAD software. I am using loop to create
multiple cylinders and I am writing following code-:
cyname = "Cylinder"
FreeCAD.ActiveDocument.addObject("Part::Cylinder",cyname)
FreeCAD.ActiveDocument.cyname.Radius= .5
FreeCAD.ActiveDocument.cyname.Height= 10

And I am getting this error-:
AttributeError: 'App.Document' object has no attribute 'cyname'


Indeed.


But when I use Cylinder in place of cyname, I am not getting any error.


Of course.



Please help.


I don't have FreeCAD installed, I won't install it, and I'm not going to 
read FreeCAD's doc neither, but you may want to check whether 
FreeCAD.ActiveDocument.addObject actually returns the newly created 
objet (which would be a sensible behaviour). If so, you'd just have to 
keep a ref to this object, ie:


cylinder = FreeCAD.ActiveDocument.addObject("Part::Cylinder",cyname)
cylinder.Radius = 0.5
# etc

Else, you can always get this ref using getattr, ie:

FreeCAD.ActiveDocument.addObject("Part::Cylinder",cyname)
cylinder = getattr(FreeCAD.ActiveDocument, cyname)
cylinder.Radius = 0.5
# etc

And while you're at it, you could save on both typing and execution time 
by keepin a ref to the document object itself:


doc = FreeCAD.ActiveDocument

for cyname in ("cylinder1, "cylinder2", "cylinderN"):
doc.addObject("Part::Cylinder",cyname)
cylinder = getattr(doc, cyname)
cylinder.Radius = 0.5
# etc

HTH
--
http://mail.python.org/mailman/listinfo/python-list


EARN 10$ PER ADVERTISEMENT OF 60 SEC

2010-08-17 Thread tania tani

MESSAGE NO 1 FOR YOU READ IT.

http://www.fineptc.com/index.php?ref=imranraza460

Hello
 my dear friend,


I hope you will be fine. i want to tell you the
authentic way to make
 money with no investment.

 Here you can make 60 dollars in just six minutes. No
investment its
 free.Trial is essential...

   1 Just click on the obove link

   2 create your account on the website.

 ( it will take 2 or three minutesits absouloutely free no
subscription fee )

   3 Now loging with your username and the password

   4 Then click on the "" view adds"" tab

   5 There will be 6 or 7 adds links ( consisting 60 seconds
each )

   6 Click on a particular add and watch it for 1 min.  (when you
click on a add link , remember open  one add at  a time.  a
new window will be open and a countdown timing for one minute will be
start on upper left side ofthe web page when its staps you
will be asked to click a specific number eg click 1  1 2 3 4. you have
to   click on it)

   7 This one minute add will give you 10 US $ DOLLAR.

   8 Hence watch other adds  one by one.

   9 Finally you will find 60 dollars on you status by checking "'
my account "'

   10You have earned 60 dollars you can repeat you view adds again
on next day

 moreover if you introduce a new guy with your reffence you
will be entitled to

 get 50% of the refferal(which means that if the person
reffered by you take his

 /her adds daily he will receives dollars you will be 50% of
his/her daily work.

Trust me its free and its really works

   11This is not a Fake.This is 100% sure you will get your money.

 CLICK ON THE ABOVE LINK NEAR "MESSAGE NO 1 FOR
YOU"..RIGHT NOW

 IMPORTANT INSTRUCTIONS: YOU CAN TAKE YOUR UNIQUE REFFERAL LINK BY
CLICKING ON "PROMOTE" OPTION ON THE WEB SITE. YOU CAN FEED BACK ME ON
THIS E MAIL ID. "imran.raza...@gmail.com"


MESSAGE NO 2 FOR YOU READ IT.

http://www.buxbillionaire.com/?ref=imranraza460

Hello
 my dear friend,


I hope you will be fine. i want to tell you the
authentic way to make
 money with no investment.

 Here you can make 80 OR 40 US $ dollars in just six
minutes. No investment its
 free.Trial is essential...

   1 Just click on the obove link

   2 create your account on the website.

 ( it will take 2 or three minutesits absouloutely free no
subscription fee )

   3 Now loging with your username and the password

   4 Then click on the "" view adds"" tab

   5 There will be 4 or 8 adds links ( consisting 60 seconds
each )

   6 Click on a particular add and watch it for 1 min.  (when you
click on a add link , remember open  one add at  a time.  a
new window will be open and a countdown timing for one minute will be
start ons upper left side ofthe web page when its staps
you will be asked to click a specific number eg click 05  05 02 03 04.
click on05 you have to click on it)

   7 This one minute add will give you 10 US $ DOLLAR.

   8 Hence watch other adds  one by one.

   9 Finally you will find 40 or some time 80 US $ dollars on you
status by checking "' my account "'

   10You have earned 60 dollars you can repeat your view adds
again on next day

 moreover if you introduce a new guy with your reffence you
will be entitled to

 get 10 $ per click  of the reffferal(which means that if the
person reffered by you take his

 /her adds daily you will  be received  10 $ per add of his/
her daily work.means equal to him/her

Trust me its free and its really works

   11This is not a Fake.This is 100% sure you will get your money.

 CLICK ON THE ABOVE LINK near " MESSAGE NO 2 FOR
YOU..RIGHT NOW

 IMPORTANT INSTRUCTIONS: YOU CAN TAKE YOUR UNIQUE REFFERAL LINK BY
CLICKING ON "PROMOTION TOLLS"  OPTION ON THE WEB SITE. YOU CAN FEED
BACK ME ON THIS E MAIL ID. "imran.raza...@gmail.com"
_

MESSAGE NO 3 FOR YOU READ IT.

http://www.buxmillionaire.com/?ref=imranraza460

Hello
 my dear friend,


I hope you will be fine. i want to tell you the
authentic way to make
 money with no investment.

 Here you can make 230  US $ dollars in just 23
minutes. No investment its
 free.Trial is essential...


Re: update of elements in GUI

2010-08-17 Thread Jah_Alarm
thanks. The thing is, the objects actually get updated without this
command, but when I run the GUI outside of python shell (i.e. in
command prompt as python filename.py or compile it to .exe file) the
objects do not get updated. I tried
Label(mainframe,textvariable=var).grid(column=1,row=1).update_idletasks()
and mainframe.update_idletasks() but it still doesn't work.


On Aug 17, 7:19 pm, Eric Brunel 
wrote:
> In article
> <24dc97b3-a8b5-4638-9cf5-a397f1eae...@q16g2000prf.googlegroups.com>,
>
>  Jah_Alarm  wrote:
> > hi, I've already asked this question but so far the progress has been
> > small.
>
> > I'm running Tkinter. I have some elements on the screen (Labels, most
> > importantly) which content has to be updated every iteration of the
> > algorithm run, e.g. "Iteration =" [i] for i in range(n), n=100. I'm
> > using the update_idletasks() command in the function itself after the
> > variable.set(...) command. The variable type is IntVar(), and the
> > mistake I'm getting is 'IntVar instance has no attribute
> > 'update_idletasks'. No updates are displayed, of course.
>
> You have to call update_idletasks on a Tkinter *widget*, not a variable.
> You can call it on your window (Tk or Toplevel instance) or on your
> label for example. This way, it should work.
>
>
>
> > Without the GUI the algorithm (it's a genetic algorithm) is working
> > fine, but I need to make it available to other people via GUI
>
> > cheers,
>
> > Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2 Regex Questions

2010-08-17 Thread AlphaBravo
On Aug 17, 10:23 am, Peter Otten <__pete...@web.de> wrote:
> AlphaBravo wrote:
> >  2) How can I split a string into sections that MATCH a regex (rather
> > then splitting by seperator). Tokenizer-style but ignoring every place
> > from where I can't start a match?
> >>> import re
> >>> re.compile("[abc]+").findall("abcxaaa! abba")
>
> ['abc', 'aaa', 'abba']

Thanks for 2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python Sandbox

2010-08-17 Thread Roland Koebler
On Sat, Aug 14, 2010 at 08:01:00PM -0700, Stephen Hansen wrote:
> > As you can see, black listing isn't the best approach here.
> 
> But I have a two pronged strategy: the black list is only half of the
> equation. One, I'm blacklisting all the meta functions out of builtins.
But blacklists are *never* secure. Sorry, but you should fully understand
this before even thinking about more detailed security.

Why are you blacklisting the "known-bad" functions instead of whitelising
the allowed ones??

regards,
Roland

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Jean-Michel Pichavant

Michele Simionato wrote:

On Aug 17, 6:50 am, AK  wrote:
  

On 08/17/2010 12:26 AM, James Mills wrote:
By the way, the reason I asked is that we're working on a python
tutorial and I realized that even though I'm used to 99, I wasn't sure
if it's ok to teach that to new users or not..

   -andrei



It is certainly NOT useful to teach a convention which is explicitly
discouraged in the Python guidelines (PEP 8). Having said that, I
particularly *hate* people using long lines, and I usually reindent
the code of my coworkers not following that convention.
The reason is that my Emacs is set to 79 chars and longer code looks
ugly, that I look at two-side diffs all the time, and that sometimes I
want to print on paper the code I have to work with. OTOH, I do not
see a single advantage in using long lines.

 Michele Simionato
  
Using long lines can sometimes improve readability, procude better 
shaped code, 'cause wrapping code to 79 chars may not be "natural" in 
all cases.


We do have a strong habit using meaningfull & plain names in our code, 
no i, j, k ; cmdLine is always replaced by commandLine. So lines can 
easily exceed 79 chars and wrapping it would'nt be easy.
I'm not saying wrapping to 79 is wrong, I'm just saying that they are 
advantages of using long lines (the 1st obvious one being not to care 
about wrapping text).


Saying that, if one intend to distribute its code, he should stick to 80 
chars per line.


JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: segfault with small pyqt script

2010-08-17 Thread Hans-Peter Jansen
On Monday 16 August 2010, 09:22:27 Gelonida wrote:
> Hi Hans-Peter,
>
>
> It seems, that my other posts did not get through.
>
> On 08/15/2010 11:17 PM, Hans-Peter Jansen wrote:
> > For a starter, tell us the versions of python-sip, and python-qt4 or
> > however they're called in Ubuntu. For the record,
> > python-sip-4.10.5-1.1
> > python-qt4-4.7.4-1.1
> > doesn't show this behavior.
> >
>
> The problem seems to be known for 4.7.2.
> For simple code I managed to work around the issue.
> For the real more complicated I didn't. So it seems
> I'll have to avoid 4.7.2.
>
[...]
>
> For more complex multi widget examples it doesn't seem enough to just
> destroy the main widget.
> probably I had to recursively assign all widgets / dialogues sub widgets
> to None.
>
> So I'll just try to stay away from this pyqt release and stick with
> older or newer ones.

If you test sip 4.10.5 by chance, it would be nice to leave a brief note 
about the outcome. As long as you replace (qscintilla, if you use it), sip 
and PyQt, the probability of a bad influence on your system is pretty 
small. Replacing PyKDE aka kdebindings4 might not be that easy, though..

I might even get around also building Ubuntu packages in openSUSE build 
service one day... Various openSUSE builds are available here:
http://download.opensuse.org/repositories/home:/frispete:/pyqt/

Pete
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looping through possible combinations of McNuggets packs of 6, 9 and 20

2010-08-17 Thread Giacomo Boffi
Paul Rubin  writes:

> Baba  writes:
>> exercise: given that packs of McNuggets can only be bought in 6, 9 or
>> 20 packs, write an exhaustive search to find the largest number of
>> McNuggets that cannot be bought in exact quantity.
>
> Is that a homework problem?

yes, and no

it was a homework problem, assigned in 2008, as clearly stated by the OP

most of what was discussed on the ng was clearly stated in the
introduction to the actual problem, so that we can thank Baba for NOT
having read the text of the assignment, leavin' us a couple of days of
amusing and interesting posts
-- 
Mangiate pure le vostre carote, noi mangeremo le nostre salsicce!
   -- Claud,   in IHC
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Michele Simionato
On Aug 17, 6:50 am, AK  wrote:
> On 08/17/2010 12:26 AM, James Mills wrote:
> By the way, the reason I asked is that we're working on a python
> tutorial and I realized that even though I'm used to 99, I wasn't sure
> if it's ok to teach that to new users or not..
>
>    -andrei

It is certainly NOT useful to teach a convention which is explicitly
discouraged in the Python guidelines (PEP 8). Having said that, I
particularly *hate* people using long lines, and I usually reindent
the code of my coworkers not following that convention.
The reason is that my Emacs is set to 79 chars and longer code looks
ugly, that I look at two-side diffs all the time, and that sometimes I
want to print on paper the code I have to work with. OTOH, I do not
see a single advantage in using long lines.

 Michele Simionato
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 79 chars or more?

2010-08-17 Thread Lawrence D'Oliveiro
In message , AK wrote:

> As monitors are getting bigger, is there a general change in opinion on
> the 79 chars limit in source files?

WHAT 79-character limit in source files?

I currently have my Emacs windows set at 100 characters wide, and I’m 
thinking of going wider.

Remember, the old hardcopy terminals used to produce 132-character-wide 
listings.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2 Regex Questions

2010-08-17 Thread Peter Otten
AlphaBravo wrote:

>  2) How can I split a string into sections that MATCH a regex (rather
> then splitting by seperator). Tokenizer-style but ignoring every place
> from where I can't start a match?

>>> import re
>>> re.compile("[abc]+").findall("abcxaaa! abba")
['abc', 'aaa', 'abba']

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Textvariable display in label (GUI design)

2010-08-17 Thread Eric Brunel
In article 
,
 Jah_Alarm  wrote:

> On Aug 17, 3:32 am, Eric Brunel 
> wrote:
> > In article
> > <993d9560-564d-47f0-b2db-6f0c6404a...@g6g2000pro.googlegroups.com>,
> >
> >  Jah_Alarm  wrote:
> > > hi,
> >
> > > pls help me out with the following issue: I wrote a function that uses
> > > a for loop that changes a value of a certain variable each iteration.
> > > What I want is by clicking a button in GUI (with the command bound to
> > > this function) this value each iteration is displayed in a textbox
> > > (label). So far only one (starting value) is displayed.
> >
> > > thanks,
> >
> > > Alex
> >
> > First, with posts like this, you're highly unlikely to get any useful
> > answer: please strip down your code to the smallest part that displays
> > the problem, post this code here, explaining what you're expecting and
> > what you're getting. Otherwise, people just won't know what you're
> > talking about unless they have a crystal ballÅ 
> >
> > Now using my own crystal ball: if you don't return the control to the
> > GUI each time your variable is increased, the GUI won't get a chance to
> > update itself. Since you seem to use Tkinter (another wild guessÅ ), you
> > probably need a call to the update_idletasks method on any Tkinter
> > widget each time you change your TextVariable.
> >
> > HTH
> >  - Eric -
> 
> Thanks, but where is this command used, in the button than runs the
> algorithm, the label or the function itself?

Wherever you want, the only requirement being that you should have a 
widget at hand, in a class attribute or a global variable or whatever. I 
would put it just after I do any my_variable.set(…) if possible.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: update of elements in GUI

2010-08-17 Thread Eric Brunel
In article 
<24dc97b3-a8b5-4638-9cf5-a397f1eae...@q16g2000prf.googlegroups.com>,
 Jah_Alarm  wrote:

> hi, I've already asked this question but so far the progress has been
> small.
> 
> I'm running Tkinter. I have some elements on the screen (Labels, most
> importantly) which content has to be updated every iteration of the
> algorithm run, e.g. "Iteration =" [i] for i in range(n), n=100. I'm
> using the update_idletasks() command in the function itself after the
> variable.set(...) command. The variable type is IntVar(), and the
> mistake I'm getting is 'IntVar instance has no attribute
> 'update_idletasks'. No updates are displayed, of course.

You have to call update_idletasks on a Tkinter *widget*, not a variable. 
You can call it on your window (Tk or Toplevel instance) or on your 
label for example. This way, it should work.

> Without the GUI the algorithm (it's a genetic algorithm) is working
> fine, but I need to make it available to other people via GUI
> 
> cheers,
> 
> Alex
-- 
http://mail.python.org/mailman/listinfo/python-list