notify when a process exits

2011-07-28 Thread Ryan
Is there anyway in python to get a notification when a process exits?
To be completely clear, I am looking for a notification solution,
similar to pyinotify, not a polling one (I know I can poll a process
using os.kill(pid, 0)).

BTW, pyinotify will not work on /proc/pid as a solution. I have
already tried. /proc/pid is not a real directory (in the strictest
sense of the word). So, pyinotify can not watch it.

Ryan



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


__set__ method is not called for class attribute access

2011-08-05 Thread Ryan
In the context of descriptors, the __set__ method is not called for
class attribute access. __set__ is only
called to set the attribute on an instance instance of the owner class
to a new value, value. WHY? Is there some other mechanism for
accomplishing this outcome. This subtle difference from __get__cost me
some time to track down. Might think about pointing that out the
documentation.


class RevealAccess(object):
"""A data descriptor that sets and returns values
   normally and prints a message logging their access.
"""

def __init__(self, initval=None, name='var'):
self.val = initval
self.name = name

def __get__(self, obj, objtype):
print 'Retrieving', self.name
return self.val

def __set__(self, obj, val):
print 'Updating' , self.name
self.val = val

class MyClass(object):
x = RevealAccess(10, 'var "x"')
y = 5

print MyClass.x
MyClass.x = 20
print MyClass.x
MyClass.x = 30
print MyClass.x

Retrieving var "x"
10
20
30

I am at a lost on how to intercept class attribute sets. Can anyone
help :-/

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


Re: Can one use Python to learn and even apply Functional Programming?

2014-02-16 Thread Ryan
Python*can* do functional programming, but, for learning, Haskell will work 
better.

Sam  wrote:
>I would like to learn and try out functional programming (FP). I love
>Python and would like to use it to try FP. Some have advised me to use
>Haskell instead because Python is not a good language for FP. I am sort
>of confused at the moment. Is Python a dysfunctional programming
>language to apply FP? Can the more experienced Python users advise?
>-- 
>https://mail.python.org/mailman/listinfo/python-list

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.-- 
https://mail.python.org/mailman/listinfo/python-list


Extending Python with C or C++

2009-01-05 Thread Ryan
I've been using Python for many years now. It's a wonderful language
that I enjoy using everyday. I'm now interested in getting to know
more about the guts (C/C++) and extending it. But, extending python
still seems like a black art to me. Is there anymore docs or info on
extending it besides the standard sparse ones (http://www.python.org/
doc/2.5.2/ext/intro.html) that may give me more insight? Is there a
class available? How can I learn more about the guts of python? How
would one go about following an interest in contributing to the
development of python.

Thanks,

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


Re: Extending Python with C or C++

2009-01-05 Thread Ryan
On Jan 5, 2:37 pm, Terry Reedy  wrote:
> Ryan wrote:
> > I've been using Python for many years now. It's a wonderful language
> > that I enjoy using everyday. I'm now interested in getting to know
> > more about the guts
>
> The 'guts' of Python the language include the object model, namespaces
> (including modules), and the statement and infix-expression syntax.
>
> > (C/C++) and extending it.
>
> Now you are asking about CPython, the leading computer implementation.
>
> > But, extending python still seems like a black art to me.
>
>  > Is there anymore docs or info on
>
> > extending it besides the standard sparse ones (http://www.python.org/
> > doc/2.5.2/ext/intro.html) that may give me more insight? Is there a
> > class available?
>
> If you want to connect CPython to Python-oblivious code written in C,
> Swig (with C code) and Ctypes (with Python code) are the main choices.
> If you want to write new Python-aware (and specific) code, you can use
> the CPython C-API functions.  Extensions in C are written as importable
> modules.  The interface for such is not difficult; existing examples
> should be a good guide.
>
>  > How can I learn more about the guts of python?
>
> The 'guts' of an implementation follow from the 'guts' of the language.
>   There must be a syntax parser and compiler to internal form,
> evaluation loop, and implemenations of built-in constants, functions,
> classes, and modules.  CPython's source tree begins 
> ashttp://svn.python.org/view/
> You might actually want to start athttp://svn.python.org/view/python/trunk/
> Note: if you click a filename, such as 'setup.py', you get the entire
> revision history with checkin messages.
> If you click the displayed revision number, such as '67978', you get the
> latest checkin message and the current version of the file.
>
> > How would one go about following an interest in contributing to the
> > development of python.
>
> Readhttp://python.org/dev/
> and start following the pydev list, mirrored to gmane.comp.python.devel
> at news.gmane.org.
>
> Terry Jan Reedy

Thanks Terry! This clarifies many of the concepts that I want to get
started to dive deeper into CPython.

1. The abstract Python Language (not specific to any implementation)
2. The CPython implementation (http://svn.python.org/view/python/
trunk/)
3. Extending CPython by connecting it to Python-oblivious code written
in C with Ctypes (Ralf's suggestion is good for this)
4. Extending CPython by connecting it to Python-aware (and specific)
code using the CPython C-API functions (http://docs.python.org/c-api/)
--
http://mail.python.org/mailman/listinfo/python-list


socket programming (client-server)

2008-10-22 Thread ryan
i have implemented a small client server model to do file transfer
over a LAN network.

It work with some machines on the network and on others it doesnt.
when i run the server.py file in some machine then it pops up a
windows security alert.

The message is as follows:

  Do you want to keep blocking this program?
there are three options below it. 1. Keep Blocking 2. Unblock 3. Ask
Me later.

I selected the option  unblock.Even then the client and server are not
able to communicate.
I get a error saying that:-

socket.error: (10060, 'Operation timed out')

I guess its a firewall problem... How do i go abt it?
any help?
--
http://mail.python.org/mailman/listinfo/python-list


Re: socket programming (client-server) error

2008-10-22 Thread ryan
On Oct 22, 6:18 pm, Python <[EMAIL PROTECTED]> wrote:
> On 22 okt 2008, at 13:50, ryan fox wrote:
>
>
>
> > i have implemented a small client server model to do file transfer
> > over a LAN network.
>
> > It work with some machines on the network and on others it doesnt.
> > when i run the server.py file in some machine then it pops up a
> > windows security alert.
>
> > The message is as follows:
>
> >      Do you want to keep blocking this program?
> > there are three options below it. 1. Keep Blocking 2. Unblock 3. Ask
> > Me later.
>
> > I selected the option  unblock.Even then the client and server are not
> > able to communicate.
> > I get a error saying that:-
>
> > socket.error: (10060, 'Operation timed out')
>
> > I guess its a firewall problem... How do i go abt it?
> > any help? --
>
> does it work if you temporarily switch off the firewall?
>
> gr
> Arno

HI arno ,

In the firewall setting i have unblocked this program and tried. But
it works on some machines on the LAN and doesnt work on other
machines.
Even if the firewall is on it work on some machines. So narrowing down
on the problem seems tough here

any ideas?
--
http://mail.python.org/mailman/listinfo/python-list


running pyhton IDLE on windows vista

2009-03-30 Thread ryan
Hi guys ,

I am facing  problems running python25 on vista . i was able to
successfully install it but when i try to run it then,
its throws errors saying Firewall issues ..

I tried disabling the firewall but no go..

Thanks in advance!!

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


del an imported Class at EOF... why?

2009-10-06 Thread Ryan
Good day all!

I've just inherited a large amount of python code. After spending some
time pour through the code, I've noticed that the original developer
(who is no longer w/ the company) constantly deletes the imported
classes at the end of the .py file. Why would one want to do such a
thing?

Ryan

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


Re: del an imported Class at EOF... why?

2009-10-07 Thread Ryan
Thanks everyone for your insight. I'm going to have to agree with the
paranoid desire to prevent people importing his module and then using
the
classes he imports from elsewhere (I'm not ruling out the lead paint
theory until I can gather more evidence). It does beg the question for
me. Consider the example from his code below

from PyQt4 import QtGui

class LauncherWidget( QtGui.QWidget ):
# A Specialization of QWidget

del QtGui

Next time python comes across

from PyQt4 import QtGui

it would have to re-import the class, which seems a waste of cycles
that could accumulate. In this situation, the use of __all__ is
better. Plus, by using __all__ instead of del you do not have to worry
about forgetting to del a class.


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


Migrating from R to Python

2009-11-02 Thread Ryan
I am a long time user of "R" for statistical analysis and find it an
extremely useful environment for data exploration. That said I may be
adding and/or moving to Python for more of my work and wanted to know
if people had any recommendations.

My work is primarily financial time series analysis. In R this means
extensive use of "zoo" and "xts". I see from searching that there is a
time-series package for Python called pytseries (http://
pytseries.sourceforge.net/) that looks closest to adding the time
series capabilities to Python.

My question is to people who have used zoo and xts in R, what has
their experience been with Python? Would you recommend using native
Python to do time series analysis, or rPy to link back to R for
analysis?

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


Catching a SIGSEGV signal on an import

2010-09-09 Thread Ryan
Is there anyway to catch a SIGSEGV signal that results from an import?
I'd like to get a list of all modules on the sys.path. The module
pkgutil has a nice method, walk_packages, to do just that. But, there
is a third party extension that throws a SIGSEGV when imported. I
tried to create a signal handler with the signal module like:


#!/bin/env python
import pkgutil
import signal
import traceback

def handler(signal, stackframe):
raise ImportError

# Handle seg faults that may occur during an import
signal.signal(signal.SIGSEGV, handler)

if __name__ == "__main__":
goodMods = []

def onerror(pkgName):
sys.stdout.write('Unable to import package %s\n' % pkgName)
traceback.print_exc(file=sys.stdout)
sys.stdout.write('\n')
#sys.stdout.flush()

for importer, mod, ispkg in pkgutil.walk_packages(path=None,
onerror=onerror):
goodMods.append(mod)

for m in goodMods:
sys.stdout.write(m + '\n')
sys.stdout.flush()

This sometimes works. But, since SIGSEGV is asynchronous it is not
guaranteed to work all the time. In general, is there anyway to catch
a  SIGSEGV on import? If so, is there a way to use that with
pkgutil.walk_packages to get all the modules on sys.path?

Thanks,
Ryan

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


Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Lie Ryan

On 18/01/13 02:02, Utpal Sarkar wrote:

Hi,

I was assuming that sys.stdout would be referencing the same physical stream as 
iostreams::cout running in the same process, but this doesn't seem to be the 
case.
The following code, which makes a call to a C++ function with a python wrapper called 
"write", that writes to cout:

from cStringIO import StringIO
import sys
orig_stdout = sys.stdout
sys.stdout = stringout = StringIO()
write("cout") # wrapped C++ function that writes to cout
print "-" * 40
print "stdout"
sys.stdout = orig_stdout
print stringout.getvalue()

immediately writes "cout" to the console, then the separator "---...", and finally, as 
the return value of stringout.getvalue(), the string "stdout".
My intention was to capture in stringout also the string written to cout from 
C++.
Does anyone know what is going on, and if so, how I can capture what is written 
to cout in a python string?

Thanks in advance.



You might have a better luck if you check std::ios::rdbuf 
(http://www.cplusplus.com/reference/ios/ios/rdbuf/)


Using std::ios::rdbuf() you can get the cout's streambuf, which is a 
filebuf for the stdout and then use std::ios::rdbuf(streambuf*) to 
replace cout's internal streambuf and replace it with your own 
implementation that captures everything written using cout before 
passing it back to the original streambuf.


This is essentially similar to assigning to sys.stdout in python.

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


Re: To make a method or attribute private

2013-01-17 Thread Lie Ryan

On 17/01/13 11:34, iMath wrote:

To make a method or attribute private (inaccessible from the outside),
simply start its name with two underscores

《Beginning Python From Novice to Professional》

but there is another saying goes:
Beginning a variable name with a single underscore indicates that the
variable should be treated as ‘private’.

I test both these 2 rules ,it seems only names that start with two
underscores are REAL private methods or attributes .


Python does not have a REAL private methods/attributes. The double 
leading underscore is meant to trigger name mangling to avoid naming 
collisions with subclasses, the method/attribute is still accessible 
using the mangled name:


>>> ap._A__a
'__a'

You generally only use double leading underscores when your private 
method/attribute is in a very high risk of having naming clashes with 
superclasses/subclasses.


> so what is your opinion about single leading underscore and private
> methods or attributes?

We're all consenting adults. Use methods/attributes with single or 
double leading underscore at your own risk.


Most programming languages do not actually have a private attribute that 
is totally inaccessible from outside, there are usually ways work around 
access restrictions, usually using reflections or pointers. Python only 
makes it easy to do so by making private variables only a convention.


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


Re: Vote tallying...

2013-01-18 Thread Lie Ryan

On 18/01/13 10:59, Andrew Robinson wrote:

Hi,

I have a problem which may fit in a mysql database, but which I only
have python as an alternate tool to solve... so I'd like to hear some
opinions...


Since you have a large dataset, you might want to use sqlite3 
(http://docs.python.org/2.5/lib/module-sqlite3.html, 
https://www.sqlite.org/), which comes in the standard library since 
Python 2.5. SQLite is a self-contained, serverless, zero configuration, 
transactional SQL database engine.


XML with a million entries are probably not a good idea due to its 
verbosity; XML was designed for data interchange, not for complex 
relational data processing.


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


Re: Safely add a key to a dict only if it does not already exist?

2013-01-18 Thread Lie Ryan

On 19/01/13 15:15, Chris Rebert wrote:

On Friday, January 18, 2013, Steven D'Aprano wrote:

I wish to add a key to a dict only if it doesn't already exist, but
do it
in a thread-safe manner.

The naive code is:

if key not in dict:
 dict[key] = value


but of course there is a race condition there: it is possible that

another thread may have added the same key between the check and the
store.

How can I add a key in a thread-safe manner?


I'm not entirely sure, but have you investigated dict.setdefault() ?


dict.setdefault() was not atomic on older python version, they were made 
atomic in Python 2.7.3 and Python 3.2.3.


See bug13521 in the issue tracker http://bugs.python.org/issue13521

PS: The bug tracker seems down at the moment, so pulled this from 
Google's cache:

https://webcache.googleusercontent.com/search?q=cache:59PO_F-VEfwJ:bugs.python.org/issue13521+&cd=1&hl=en&ct=clnk&client=ubuntu

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


Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Lie Ryan

On 19/01/13 21:13, Santosh Kumar wrote:

I have a working script which takes argv[1] as an input, deassembles
each line, and then each word. Then after it capitalizes all its word
(upcases the first letter) and then prints it out on the stdout.

That script does the capitalization work fine, but, when it reassemble
the the words, it does it like this:

 lines.append(' '.join(words))

The biggest problem is, even when the input file has many spaces, it
strips it down to one.


replace:

words = line.split()

with:
words = line.split(' ')

> The whole script will look clumsy here. I have put it up on GitHub,
> here is it: 
https://github.com/santosh/capitalizr.py/blob/master/capitalizr


In general, when the script is just this short, it's better to put it 
directly on the message.


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


Re: Vote tallying...

2013-01-19 Thread Lie Ryan

On 19/01/13 00:43, Andrew Robinson wrote:

On 01/18/2013 08:47 AM, Stefan Behnel wrote:

Andrew Robinson, 18.01.2013 00:59:

I have a problem which may fit in a mysql database

Everything fits in a MySQL database - not a reason to use it, though.
Py2.5
and later ship with sqlite3 and if you go for an external database,
why use
MySQL if you can have PostgreSQL for the same price?

MySQL is provided by the present server host.  It's pretty standard at
web hosting sites.
It works through "import MySQLdb" -- and it means an IP call for every
action...


That is not quite true. With most client libraries, including MySQLdb, 
connection to localhost goes through a local unix socket (or named pipe 
in Windows) instead of the TCP stack.



But
it wants to lock the entire database against reads as well as writes
when any access of the database happens.  Which is bad...


Which is the same restriction as when using XML/JSON. What it means by 
locking the entire database is that an sqlite database can only be 
read/written by a single program at any moment in time. For batch 
processing, locking the entire database is never going to be a problem; 
for CGI scripts (and their variants), it may be a performance bottleneck 
for extremely high volume websites.



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


Re: Vote tallying...

2013-01-19 Thread Lie Ryan

On 20/01/13 08:22, Dennis Lee Bieber wrote:

On Sat, 19 Jan 2013 22:58:17 +1100, Lie Ryan 



Which is the same restriction as when using XML/JSON. What it means by
locking the entire database is that an sqlite database can only be
read/written by a single program at any moment in time. For batch


Actually, SQLite3 will happily permit multiple readers (or did, the
newest version may have a new locking scheme). However, the first
connection that seeks to write will block as long as open readers are
active, yet will also block /new/ readers. When the open readers close,
the write can complete, and then new readers can enter. Conclusion:
ensure that even read-only operations have a "commit" operation to close
them


You're correct. For more precise description of what sqlite can or 
cannot do with respect to concurrency, see 
http://www.sqlite.org/faq.html#q5.


As far as I know, dbm does not support concurrencies at all, and neither 
does xml unless you put a lot of efforts into implementing your own file 
locking and all.


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


Re: why not?

2013-01-21 Thread Lie Ryan

On 22/01/13 04:02, kwakukwat...@gmail.com wrote:

f = open(r'c:\text\somefile.txt')
for i in range(3):
print str(i) + ': ' + f.readline(),
please with the print str(i) + ‘: ‘ + f.readline(), why not print str(i)
+ f.readline(),


Try running both code. What do you see? What's the difference? When do 
you think you might want one or the other?



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


Re: Is a with on open always necessary?

2012-01-25 Thread Lie Ryan

On 01/26/2012 04:17 AM, K Richard Pixley wrote:

On 1/21/12 03:38 , Lie Ryan wrote:

It is only strictly necessary for programs that opens thousands of files
in a short while, since the operating system may limit of the number of
active file handlers you can have.


The number you're looking for is 20 on many unix systems. That's all. 20
concurrently open file descriptors.

Modern systems open that number up somewhat, or make it tailorable. But
the number is still much lower than you might expect.


From what I can gather, Linux defaults to 1024, Windows 16384, and OSX 
256; I doubt many people would need to work with other OSes.


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


Re: [OT]: Smartphones and Python?

2012-02-18 Thread Lie Ryan

On 02/18/2012 12:51 PM, Michael Torrie wrote:

On 02/16/2012 10:25 PM, 8 Dihedral wrote:

Android is a customized linux OS used in mobile phones. I don't think
any linux systm has to be locked by JAVA or any JVM to run
applications.


Getting waaa off topic here, but...

I guess you aren't familiar with what Android is (which is ironic, given
that a lot of people on this list think you must be one!).  Android is
not simply a customized linux distribution.


Strictly speaking, Android *is* a customized Linux distribution; what it 
is not is Android is not a GNU/Linux distribution.



It's a special application
environment (an OS in its own right) that is based on the Dalvik virtual
machine.  Dalvik does depend on the Linux kernel to talk to the
hardware, but Linux very much is not a part of Android, at least from
the developers' and end users' points of view.  Linux is just not a part
of the user experience at all.  It is true that Dalvik can call into
native linux code, but native linux applications typically aren't a part
of the Android user experience.


Android does have a full Linux experience; what it lacks is the GNU 
experience. Unlike "normal" Linux distros, Android does not use GNU 
userspace, instead it have its own userspace based on bionic, toolbox, 
and dalvik. Linux is a core part of Android's user and developer's 
experience.


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


Re: Tools for refactoring/obfuscation

2012-03-30 Thread Lie Ryan

On 03/29/2012 03:04 AM, Javier wrote:

Yes, in general I follow clear guidelines for writing code.  I just use
modules with functions in the same directory and clear use of name
spaces. I almost never use classes.  I wonder if you use some tool for
refactoring.  I am mainly intersted in scripting tools, no eclipse-style
guis.

Just let me know if you use some scripting tool.

And, as somebody pointed in this thread obfuscating or refactoring the
code are very different things but they can be done with the same tools.


if you're not using classes, your code is obfuscated already

Anyway, I think it's better if you describe why you want such a tool. If 
you want to keep your code a secret, just distribute the .pyc file. If 
you want to refactor your code to improve readability, there is rope.


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


Re: Python is readable

2012-03-30 Thread Lie Ryan

On 03/18/2012 12:36 PM, Steven D'Aprano wrote:

On Sat, 17 Mar 2012 20:59:34 +0100, Kiuhnm wrote:
In the second example, most English speakers would intuit that "print(i)"
prints i, whatever i is.


There are two points where the code may be misunderstood, a beginner may 
think that "print i" prints to the inkjet printer (I remembered 
unplugging my printer when I wrote my first BASIC program for this 
reason); and the possible confusion of whether "print i" prints the 
letter "i" or the content of variable "i". (Fortunately, this confusion 
are easily resolved when I run the code and see the result on-screen 
instead of a job on the print spooler)


(ironically, although print is nowadays a programming jargon for 
outputting to screen, but in the old dark ages, people used to use the 
"print" statement to print to paper in their old terminal)


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


Re: Python is readable

2012-03-30 Thread Lie Ryan

On 03/21/2012 03:55 AM, Nathan Rice wrote:

In mathematics, when you perform global optimization you must be
willing to make moves in the solution space that may result in a
temporary reduction of your optimality condition.  If you just perform
naive gradient decent, only looking to the change that will induce the
greatest immediate improvement in optimality, you will usually end up
orbiting around a solution which is not globally optimal.  I mention
this because any readability or usability information gained using
trained programmers is simultaneously measuring the readability or
usability and its conformance to the programmer's cognitive model of
programming.  The result is local optimization around the
current-paradigm minimum.  This is why we have so many nearly
identical curly brace C-like languages.


I think you've just described that greedy algorithm can't always find 
the globally optimal solution.


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


Re: Python is readable

2012-03-30 Thread Lie Ryan

On 03/21/2012 01:44 PM, Steve Howell wrote:

Also, don't they call those thingies "object" for a reason? ;)


A subject is (almost?) always a noun, and so a subject is also an object.

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


Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-08 Thread Lie Ryan

On 03/30/2012 06:25 AM, Steve Howell wrote:

On Mar 29, 11:53 am, Devin Jeanpierre  wrote:


Well, what sort of language differences make for English vs Mandarin?
Relational algebraic-style programming is useful, but definitely a
large language barrier to people that don't know any SQL. I think this
is reasonable. (It would not matter even if you gave SQL python-like
syntax, the mode of thinking is different, and for a good reason.)



I don't see any fundamental disconnect between SQL thinking and Python
thinking.

List comprehensions are very close to SQL SELECTs semantically, and
not that far off syntactically.

   [row.x for row in foo if x == 3]

   select x from foo where x = 3


which is where most people get it wrong; the SQL SELECTs statement did 
not specify how the machine is going to get its answer, while the 
Python's list comprehension explicitly specify that the machine is going 
to loop over foo. In most implementation of SQL with the proper indexes 
set up, the SELECT statement above will most likely just use its index 
to avoid looping over the whole foo, and the most smartest ones might 
notice that the result query only ever contains 3 and so just use the 
count of the index (I don't know if any existing SQL engine is *that* 
smart though).


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


mbox parsing, specifically message body

2012-06-14 Thread Ryan Clough
Hello everyone, 

Is anyone familiar with a simple way to parse mbox emails in Python?  I use 
Mail::MBoxParser in perl and it provides a simple way to grab the bodies from 
the emails.  In my research online, people have suggested searching for lines 
starting with "From ", but this doesn't seem reliable to me.  I am using the 
built in mailbox module and am able to do something like:

import mailbox
for message in mbox:
print message['subject']

It would be great if you could do something like the following:
print messages['body']

Any thoughts are appreciated.

Thanks, Ryan 

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


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improvethe Dvorak Layout?

2011-06-18 Thread Lie Ryan
On 06/18/11 03:53, Xah Lee wrote:
> On Jun 15, 5:43 am, rusi  wrote:
>> On Jun 15, 5:32 pm, Dotan Cohen  wrote:
>>
>>> Thanks. From testing small movements with my fingers I see that the
>>> fourth finger is in fact a bit weaker than the last finger, but more
>>> importantly, it is much less dexterous. Good to know!
>>
>> Most of the piano technique-icians emphasis, especially those of the
>> last century like Hanon, was to cultivate 'independence' of the
>> fingers.  The main target of these attacks being the 4th finger.
>>
>> The number of potential-pianists who ruined their hands and lives
>> chasing this holy grail is unknown
> 
> Hi rusi, am afaid going to contradict what u say here.
> 
> i pretty much mastered Hanon 60. All of it, but it was now 8 years
> ago. The idea that pinky is stronger than 4th is silly. I can't fathom
> any logic or science to support that. Perhaps what u meant is that in
> many situations the use of pinky can be worked around because it in at
> the edge of your hand so you can apply chopping motion or similar.
> (which, is BAD if you want to develope piano finger skill) However,
> that's entirely different than saying pinky being stronger than 4th.
> 
> there's many ways we can cookup tests right away to see. e.g. try to
> squeeze a rubber ball with 4th and thumb. Repeat with pink + thumb.
> Or, reverse exercise by stretching a rubber band wrapped on the 2
> fingers of interest. You can easy see that pinky isn't stronger.

Except that the actual finger strength themselves are not very relevant;
the dexterity of the fingers turned out to matter more because pressing
the keys in a keyboard does not actually take a lot of power.

Finger strength is even less important in typing than piano since, since
the character produced by power press and light press are the same.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile toImprovethe Dvorak Layout?

2011-06-18 Thread Lie Ryan
On 06/19/11 15:14, rusi wrote:
> On Jun 19, 9:21 am, Lie Ryan  wrote:
>> On 06/18/11 03:53, Xah Lee wrote:
>>
>>
>>
>>> On Jun 15, 5:43 am, rusi  wrote:
>>>> On Jun 15, 5:32 pm, Dotan Cohen  wrote:
>>
>>>>> Thanks. From testing small movements with my fingers I see that the
>>>>> fourth finger is in fact a bit weaker than the last finger, but more
>>>>> importantly, it is much less dexterous. Good to know!
>>
>>>> Most of the piano technique-icians emphasis, especially those of the
>>>> last century like Hanon, was to cultivate 'independence' of the
>>>> fingers.  The main target of these attacks being the 4th finger.
>>
>>>> The number of potential-pianists who ruined their hands and lives
>>>> chasing this holy grail is unknown
>>
>>> Hi rusi, am afaid going to contradict what u say here.
>>
>>> i pretty much mastered Hanon 60. All of it, but it was now 8 years
>>> ago. The idea that pinky is stronger than 4th is silly. I can't fathom
>>> any logic or science to support that. Perhaps what u meant is that in
>>> many situations the use of pinky can be worked around because it in at
>>> the edge of your hand so you can apply chopping motion or similar.
>>> (which, is BAD if you want to develope piano finger skill) However,
>>> that's entirely different than saying pinky being stronger than 4th.
>>
>>> there's many ways we can cookup tests right away to see. e.g. try to
>>> squeeze a rubber ball with 4th and thumb. Repeat with pink + thumb.
>>> Or, reverse exercise by stretching a rubber band wrapped on the 2
>>> fingers of interest. You can easy see that pinky isn't stronger.
>>
>> Except that the actual finger strength themselves are not very relevant;
>> the dexterity of the fingers turned out to matter more because pressing
>> the keys in a keyboard does not actually take a lot of power.
> 
> Actually there are 3 factors: strength, dexterity and independence.

In piano playing yes; but in typing dexterity is the most important
factor. When typing, you don't usually need to press multiple keys at
the same time except for capitals (or if you're an emacs user) and even
when you do the keyboard will still correctly register the keypresses
(unlike playing piano, which may produce different sound), also the
range of movement in typing is much less than a piano, so finger
independence aren't as necessary in typing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Lisp : car and cdr

2011-06-18 Thread Lie Ryan
On 06/18/11 00:45, Franck Ditter wrote:
> Hi, I'm just wondering about the complexity of some Python operations 
> to mimic Lisp car and cdr in Python...
> 
> def length(L) :
>   if not L : return 0
>   return 1 + length(L[1:])
> 
> Should I think of the slice L[1:] as (cdr L) ? I mean, is the slice
> a copy of a segment of L, or do I actually get a pointer to something
> inside L ? Is the above function length O(n) or probably O(n^2) ? 
> Where are such implementation things (well) said ?
> 
> Thanks,
> 
>  franck

Your function does not mimic Lisp's car/cdr. This one does:


def car(L):
return L[0]
def cdr(L):
return L[1]
def length(L):
if not L: return 0
return 1 + length(cdr(L))

L = (a, (b, (c, (d, None
length(L)

is O(n)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to iterate on a changing dictionary

2011-06-19 Thread Lie Ryan
On 06/20/11 00:32, TheSaint wrote:
> Hello
> 
> Trying to pop some key from a dict while is iterating over it will cause an 
> exception.
> How I can remove items when the search result is true.
> 
> Example:
> 
> while len(dict):
>for key in dict.keys():
>   if dict[key] is not my_result:
>  dict.pop(key)
> else:
>condition_to_break
> print('Dictionary is over')


Others has described how to do what you wanted to do, but let's address
the main problem here, why are you iterating a dictionary?

I found that most of the time that I thought I needed to iterate through
a dictionary, it's really because I'm thinking the wrong way, and a
little bit more thought lead me to a better way that doesn't involve
iterating on the dictionary.

While there are legitimate reasons for iterating a dictionary, I'd
consider the alternatives first.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: threading : make stop the caller

2011-06-19 Thread Lie Ryan
On 06/20/11 02:52, Laurent Claessens wrote:
> 
>> Popping task off the end of the list is more efficient:
> 
>> while task_list:
>> task_list.pop().start()
> 
> That's cool. In my case it's better to do
> task_list.pop(0).start
> 
> in order to pop the first element.

then you really wanted a queue instead of a list.

There is a thread-safe `queue` module in the standard library.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: doing cross platform file work

2011-06-23 Thread Ryan Kelly
On Wed, 2011-06-22 at 10:44 -0700, Tim Hanson wrote:
> Thanks for your responses to my student question about using OS paths in 
> Python.
> 
> For the more general case, I am a Linux user interested in making my scripts 
> platform neutral, which would include Linux, Unix (including Mac), and 
> Windows.  I have looked at the python.org os segment and didn't get an answer.
> 
> Is there a library (bonus would be some tutorial material) for making sure my 
> Linux scripts access files and directories on the other platforms 
> transparently?  I don't need the information immediately, but at some point...

You could go all out and use the PyFilesystem module:

   http://packages.python.org/fs/


This provides a unified API not only for accessing files on your local
disk in a platform-agnostic manner, but also for accessing files in a
zip archive, on a remote server, in memory, and from a variety of other
sources.

Even if you only ever intend to access local files, I find the API
provided by PyFilesystem much nicer than using the various modules from
the stdlib.


  Cheers,

 Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using decorators with argument in Python

2011-06-28 Thread Lie Ryan
On 06/29/2011 02:52 AM, Jigar Tanna wrote:

> coming across to certain views from people, it is not a good practice
> to use
> decorators with arguments (i.e. @memoize() ) and instead it is good to
> just
> use @memoize. Can any of you guys explain me advantages and
> disadvantages of
> using each of them

Simplicity is one, using @decor() means you have at least three-level
nested functions, which means the code is likely to be very huge and
perhaps unnecessarily.

However, there is nothing wrong with using decorators with arguments;
except that if you have a simpler alternative, then why use the more
complex ones?
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: Sprints

2011-06-28 Thread Ryan Kelly
Hi Everyone,


We have confirmed arrangements for two days of Sprints following PyCon
Au this year.  This will be a great opportunity to contribute to the
Python ecosystem under the guidance of experienced developers, so bring
your laptops!

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:
 
 1. Post-Conference Sprints
 2. Thanks to our Sponsors
 
Please pass this message on to those you feel may be interested.

 

Post-Conference Sprints
===

We are taking up the global PyCon tradition of post-conference sprints
this year at PyCon Au.

A Sprint is an opportunity for people to get together and do focussed
development on a project in a fun and welcoming atmosphere. Experienced
developers will be on hand to help newcomers get started, so bring your
laptops and take this opportunity to contribute to the Python ecosystem!

The sprints will be held on the 22nd and 23rd of August at the Sydney
Masonic Center.  Sprint leaders and topics so far include:

   Nick Coghlan:   Python core development
   Audrey Roy/Danny Greenfeld: Django and/or Packaginator
   Richard Jones:  Python Package Index


For more information and updates see:

http://www.pycon-au.org/2011/sprints/

Please register your interest by emailing pycon-...@pycon-au.org.



Thanks to our Sponsors
==

Thanks once again to the following companies for their continuing
support of Python and for helping to make PyCon Australia 2011 a
reality:

Gold:  Google  <http://www.google.com.au/>
Gold:  ComOps  <http://www.comops.com.au/>
 
Silver:  Anchor<http://anchor.com.au/>
Silver:  Enthought <http://www.enthought.com/>
Silver:  Python Software Foundation<http://www.python.org/psf/>
Silver:  WingWare  <http://www.wingware.com/>
Silver:  Superior Recruitment  <http://superiorrecruitment.com.au/>
 

Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
 



Ryan Kelly
PyCon Australia 2011




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


PyCon Australia 2011: Schedule Announced

2011-07-13 Thread Ryan Kelly
Hi Everyone,


The official schedule for PyCon Australia 2011 has been announced!

This year's conference will feature 3 fantastic keynotes, 7
introductory classroom sessions, and 26 presentations on topics as
diverse as web programming, benchmarking, social issues and API design.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:
 
 1. Conference Schedule Announced
 2. More Sponsors Announced
 
Please pass this message on to those you feel may be interested.

 

Conference Schedule Announced
=

The detailed conference schedule has been completed and can now be
viewed at the following URL:

http://pycon-au.org/2011/conference/schedule/

There's even an iCal version for you to plug the schedule straight into
your calendar of choice:

http://pycon-au.org/2011/conference/schedule/ical/


Thanks again to all our presenters for some outstanding talk proposals
this year.

  Standard Talks:

A Python on the Couch  (Mark Rees)
Behaviour Driven Development  (Malcolm Tredinnick)
Benchmarking stuff made ridiculously easy  (Tennessee Leeuwenburg)
Bytecode: What, Why, and How to Hack it  (Ryan Kelly)
Developing Scientific Software in Python  (Duncan Gray)
Fun with App Engine 1.5.0  (Greg Darke)
Hosting Python Web Applications  (Graham Dumpleton)
How Python Evolves (and How You Can Help Make It Happen)  (Nick Coghlan)
Infinite 8-bit Platformer  (Chris McCormick)
Networking Libraries in Python.  (Senthil Kumaran)
Pants - Network Programming Made Easy  (Evan Davis)
Say What You Mean: Meta-Programming a Declarative API  (Ryan Kelly)
State of CPython and Python Ecosystem  (Senthil Kumaran)
Sysadmins vs Developers, a take from the other side of the fence  (Benjamin 
Smith)
Teaching Python to the young and impressionable  (Katie Bell)
The NCSS Challenge: teaching programming via automated testing  (Tim 
Dawborn)
Weather field warping using Python.  (Nathan Faggian)
Zookeepr: Home-grown conference management software  (Brianna Laugher)

  In-Depth Talks:

Ah! I see you have the machine that goes "BING"!  (Graeme Cross)
Easy site migration using Diazo and Funnelweb  (Adam Terrey)
How to maintain big app stacks without losing your mind  (Dylan Jay)
Introduction to the Geospatial Web with GeoDjango  (Javier Candeira)
Pyramid: Lighter, faster, better web apps  (Dylan Jay)
Web micro-framework battle  (Richard Jones)

  Discussion Panels:

Panel: Python 3  (Nick Coghlan, Raymond Hettinger, Richard Jones)
Panel: Python in the webs  (Malcolm Tredinnick, Russell Keith-Magee, Dylan 
Jay, Richard Jones)

  Classroom Track:

Python 101+  (Peter Lovett)
Python's dark corners - the bad bits in Python and how to avoid them  
(Peter Lovett)
Confessions of Joe Developer (Danny Greenfeld)
Meta-matters: using decorators for better Python programming  (Graeme Cross)
Python for Science and Engineering, Part 1  (Edward Schofield)
Python for Science and Engineering, Part 2  (Edward Schofield)
The Zen of Python  (Richard Jones)



More Sponsors Announced
===


We are delighted to announce that Bitbucket by Atlassian has joined us
as a Silver Sponsor.  Thanks once again to the following companies for
their continuing support of Python and for helping to make PyCon
Australia 2011 a reality:


Gold:  Google  <http://www.google.com.au/>
Gold:  ComOps  <http://www.comops.com.au/>
 
Silver:  Anchor<http://anchor.com.au/>
Silver:  Enthought <http://www.enthought.com/>
Silver:  Python Software Foundation<http://www.python.org/psf/>
Silver:  WingWare  <http://www.wingware.com/>
Silver:  Arclight  <http://www.arclight.com.au/>
Silver:  Bitbucket by Atlassian<http://bitbucket.org/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
 



Ryan Kelly
PyCon Australia 2011






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


Re: Inconsistencies between zipfile and tarfile APIs

2011-07-21 Thread Ryan Kelly
On Fri, 2011-07-22 at 01:45 -0400, Terry Reedy wrote:
> On 7/22/2011 12:48 AM, rantingrick wrote:
> > On Jul 21, 11:13 pm, Corey Richardson  wrote:
> >> Excerpts from rantingrick's message of Thu Jul 21 23:46:05 -0400 2011:
> >>
> >>> I may have found the mother of all inconsitency warts when comparing
> >>> the zipfile and tarfile modules. Not only are the API's different, but
> >>> the entry and exits are differnet AND zipfile/tarfile do not behave
> >>> like proper file objects should.
> >>
> >> I agree, actually.
> 
> Hmm. Archives are more like directories than files. Windows, at least, 
> seems to partly treat zipfiles as more or less as such. Certainly, 7zip 
> present a directory interface. So opening a zipfile/tarfile would be 
> like opening a directory, which we normally do not do. On the other 
> hand, I am not sure I like python's interface to directories that much.

Indeed.  Actually, I'd say that archives are more like *entire
filesystems* than either files or directories.

We have a pretty nice ZipFS implementation as part of the PyFilesystem
project:

  http://packages.python.org/fs/


If anyone cares enough to whip up a TarFS implementation it would be
gratefully merged into trunk.  (There may even be the start of one in
the bugtracker somewhere, I don't recall...)


  Cheers,

Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: Registration Deadlines

2011-07-23 Thread Ryan Kelly


Hi Everyone,


Registrations for PyCon Australia 2011 are closing soon!

The conference is now less than a month away, so we need to start
finalising numbers for shirts, catering and the venue itself.  If 
you're planning to attend, please register now so you don't miss out.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:
 
 1. Registration Deadlines
 2. More Sponsors Announced
 
Please pass this message on to those you feel may be interested.

 

Registration Deadlines
==

Registrations for the conference will be closing soon, as we have the
following deadlines approaching fast:

  29th July:T-Shirt order finalised
  8th August:   Special dietary needs finalised
  15th August:  Last chance to get tickets!


If you're looking forward to adding a PyCon Au 2011 T-Shirt to your
collection, please complete your registration *this week* so we can get
one in your size.  We will be sending the order through to the printers
based on the sizes requested so far.

If you have special dietary needs (e.g. vegetarian, vegan, gluten-free)
then please complete your registration by Monday the 8th of August.  We
cannot accommodate special dietary orders submitted after this time.

All registrations will close on Monday the 15th of August, so that we 
can confirm final numbers with the venue and catering.  There will be
*no* registrations accepted after this date.

In particular, we will *not* accept registrations at the door.

So don't delay, register now at:

http://pycon-au.org/reg



More Sponsors Announced
===


We are delighted to confirm that Microsoft will be joining us this year
as a Silver Sponsor.  Thanks once again to the following companies for
their continuing support of Python and for helping to make PyCon
Australia 2011 a reality:


Gold:  Google  <http://www.google.com.au/>
Gold:  ComOps  <http://www.comops.com.au/>
 
Silver:  Anchor<http://anchor.com.au/>
Silver:  Enthought <http://www.enthought.com/>
Silver:  Python Software Foundation<http://www.python.org/psf/>
Silver:  WingWare  <http://www.wingware.com/>
Silver:  Arclight  <http://www.arclight.com.au/>
Silver:  Bitbucket by Atlassian<http://bitbucket.org/>
Silver:  Microsoft <http://www.microsoft.com/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
 



Ryan Kelly
PyCon Australia 2011


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


PyCon Australia 2011: Registration Back Online

2011-07-27 Thread Ryan Kelly


Hi Everyone,


After a brief hiatus, registrations for PyCon Australia 2011 are back
online!  We have extended some registration deadlines to compensate
for the outage.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:

 1. Registration Back Online
 2. Call for Volunteers
 3. Convore Group
 4. Thanks to our Sponsors
 
Please pass this message on to those you feel may be interested.

 

Registration Back Online


Registrations are back online after a brief PayPal outage:

http://pycon-au.org/reg


Our apologies to those inconvenienced.  PayPal put a temporary lock on 
our account while they were reviewing our status as a non-profit.  Many
thanks to the hard-working folks at Linux Australia for following up with
all the necessary paperwork.

To compensate for the outage we have adjusted some of our registration
deadlines.  The new dates are:

  1st August:   T-Shirt order finalised
  8th August:   Special dietary needs finalised
  15th August:  Last chance to get tickets!

Remember, registrations must close on Monday the 15th of August, and we will
not be accepting registrations at the door.

So don't delay, register now at:

http://pycon-au.org/reg



Call for Volunteers
===

A community conference such as PyCon just can't run without the work of
many generous volunteers.  If you're interested in helping out, please 
send us an email at:

pycon-...@pycon-au.org


We're currently looking for people to help with the following:

  * Session Staff
(see http://pycon-au.org/2011/helping/session_staff/)

  * Bag Packers
(Friday afternoon; also just general setup of the venue)

  * Registration Desk



Convore Group
=

We've set up a group on Convore for anyone wanting to chat about the 
conference:

https://convore.com/pycon-au-2011/


There are already some good tips from Sydney-siders who know the area
around the venue.  If you have any more, please share!

Don't forget, you can also follow us on Twitter for the latest updates:

https://twitter.com/pyconau
https://twitter.com/#!/search/pyconau



Thanks to our Sponsors
==


Thanks once again to the following companies for their continuing support 
of Python and for helping to make PyCon Australia 2011 a reality:


Gold:  Google  <http://www.google.com.au/>
Gold:  ComOps  <http://www.comops.com.au/>
 
Silver:  Anchor<http://anchor.com.au/>
Silver:  Enthought <http://www.enthought.com/>
Silver:  Python Software Foundation<http://www.python.org/psf/>
Silver:  WingWare  <http://www.wingware.com/>
Silver:  Arclight  <http://www.arclight.com.au/>
Silver:  Bitbucket by Atlassian<http://bitbucket.org/>
Silver:  Microsoft <http://www.microsoft.com/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.
 



Ryan Kelly
PyCon Australia 2011


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


Code War at PyCon Au 2011

2011-08-01 Thread Ryan Kelly


A huge hit at PyCon-Au last year, Code War is back!

Eight teams, onstage knockout rounds of short programming bouts, loud  
crowd...mildly impressive prizes. Any language allowed, no holds  
bared. Think of it like cage fighting for coders.

Originally based on an idea from the book PeopleWare, CodeWar has been  
run in conjunction with the Sydney WebDU conference since 2008 with  
great success. To help share the mayhem we're proud to bring CodeWar  
to PyCon-au 2011, with experienced CodeWar compare Robin Hilliard from  
RocketBoots on the microphone to keep a wry eye on proceedings.
All comers welcome -- no conference ticket required. Come to compete  
or just come to watch. RSVP now!

If you want to enter a team read on...


Tourney Rules
-

The competition will consist of three rounds:
  * 8 teams of 3-5 people
  * 1 laptop per team connected to projector on stage.
  * Rounds are first-past-the-post simple programming challenges
  * Any programming language you want.

We guarantee this won't be mind twisting problems for algorithm heads.  
It will help to have a team with a mix of skills, a clever and/or  
intimidating team name and vocal cheer squad.

For example: "Here is the complete text of pride and prejudice on this  
usb key. Be the first to print out the 7th and 25th sentances that  
contain both 'Elizabeth'and 'Darcy'". See a list of questions from  
recent code war events.

If you're registering a team, the team leader should get 1 team leader  
ticket and the team members a RSVP ticket. Don't forget to bring your  
team and single laptop on the day.

If all the team slots are gone register your standby team in case of a  
no-show.

http://codewarpyconau.eventbrite.com/



Thanks to Dylan Jay of PretaWeb for organising CodeWar this year.


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


Re: import hooks (PEP 302) broken in Python >=2.5?

2011-08-07 Thread Ryan Kelly
On Sun, 2011-08-07 at 11:11 -0700, Josh Haberman wrote:
> When reading about import hooks, I came across a blog entry comment
> that says:
> 
>   One additional thing to note about ihooks is that it's
>   somewhat seriously broken on Python 2.5 and newer and there
>   seems to be little or no interest in fixing it. It's
>   probably worth *always* avoiding when writing new code.
> 
> --http://orestis.gr/blog/2008/12/20/python-import-hooks/#c264
> 
> Does anyone know what this is referring to?  Should I be wary of
> relying on import hooks?

I believe that comment is referring specifically to "ihooks" the stdlib
module, not "import hooks" the general concept as defined in PEP302.
The former pre-dates the later.

I use custom PEP302 loaders all the time and they work fine in at least
2.6, 2.7 and 3.2.


  Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: Registration Closing Soon!

2011-08-10 Thread Ryan Kelly

Hi Everyone,


Registrations for PyCon Australia 2011 are closing soon!

The conference is just over a week away, so we need final numbers in the
next few days.  If you're planning to attend, please register now!

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:
 
 1. Registration Closing Soon
 2. Coffee
 3. Hosting Panel
 4. More Sponsors Announced
 
Please pass this message on to those you feel may be interested.

 

Registration Closing Soon
=

Full Registrations for the conference will be closing on:

Monday 15th August:  Full Registrations close

That's only five days away, so register now to be sure you don't
miss out.

By request, we will still allow latecomers to register until just before
the conference.  However, since it's after the deadline for catering and
printing, you won't be entitled to a T-shirt or a seat at the conference
dinner:

Thursday 18th August:  Last-Minute Registrations close

Please note that we will *not* accept registrations at the door.

So don't delay, register now at:

http://pycon-au.org/reg



Coffee
==

Thanks to gold sponsors Arclight, we will be able to provide one of the
most requested additions to this year's conference:  Coffee!

Yes, Arclight have generously agreed to provide a free coffee cart for
the duration of the conference.  And there was much rejoicing.



Hosting Panel
=

Saturday evening will feature an informal panel discussion with several
hosting providers.  Come and hear from our hosting panel about why their
services are right for hosting your next Python project! Each group will
give a quick 5 minute spiel, to be followed by a casual drink before the
conference dinner.

This event is happening in a private area at Mr B's pub, across the street
from the SMC. As this is a licensed venue anyone under 18 will have to be
accompanied by a parent or guardian.



More Sponsors Announced
===

We are delighted to confirm that the Django Software Foundation and Ninefold
have joined as Silver sponsors.  In addition, Arclight have upgraded to Gold
Sponsorship, Anchor have agreed to sponsor video production, and GitHub will
be sponsoring internet access.

Thanks once again to the following companies for their continuing support of
Python and for helping to make PyCon Australia 2011 a reality:


Gold:  Google <http://www.google.com.au/>
Gold:  ComOps <http://www.comops.com.au/>
Gold:  Arclight   <http://www.arclight.com.au/>
 
Video:  Anchor<http://anchor.com.au/>

Silver:  Enthought<http://www.enthought.com/>
Silver:  Python Software Foundation   <http://www.python.org/psf/>
Silver:  WingWare <http://www.wingware.com/>
Silver:  Bitbucket by Atlassian   <http://bitbucket.org/>
Silver:  Microsoft<http://www.microsoft.com/>
Silver:  Django Software Foundation   <http://www.djangoproject.com>
Silver:  Ninefold <http://ninefold.com/>

Internet:  GitHub <http://github.com/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.



Ryan Kelly
PyCon Australia 2011



-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details

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


Re: Is this a safe use of eval?

2011-02-24 Thread Ryan Kelly
On Thu, 2011-02-24 at 10:48 +0200, Frank Millman wrote:
> Hi all
> 
> I know that the use of 'eval' is discouraged because of the dangers of 
> executing untrusted code.
> 
> Here is a variation that seems safe to me, but I could be missing something.
> 
> I have a class, and the class has one or more methods which accept various 
> arguments and return a result.
> 
> I want to accept a method name and arguments in string form, and 'eval' it 
> to get the result.
> 
> Assume I have an instance called my_inst, and a method called 'calc_area', 
> with arguments w and h.
> 
> I then receive my_string  = 'calc_area(100, 200)'.
> 
> >>> result = eval('my_inst.{0}'.format(my_string))
> 
> This will only work if the string contains a valid method name with valid 
> arguments.
> 
> Can anyone see anything wrong with this?

Yes.  A serious problem.

Here's an example of what you describe:


>>> class MyClass(object):
... def calc_area(self,x,y):
... return 42
... 
>>> inst = MyClass()
>>>
>>> def testit(query):
... return eval("inst.{0}".format(query))
>>>

It works as you expect when used properly:

>>> testit('calc_area(3,4)')
42

But actually it allows all sorts of nasty things.  Watch me open an
arbitrary file on your system (assuming you have permission of course).

First find out how to access the "file" builtin:

>>> testit('__class__.__mro__[-1].__subclasses__().index(file)')
58

Great, plug that in and we're in business:

>>> testit('__class__.__mro__[-1].__subclasses__()[58]("/secret/file","w")')
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in testit
  File "", line 1, in 
IOError: [Errno 2] No such file or directory: '/secret/file'
>>>

So please, don't do this!  :-)


   Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is this a safe use of eval?

2011-02-24 Thread Ryan Kelly
On Thu, 2011-02-24 at 20:13 +1100, Ryan Kelly wrote:
> On Thu, 2011-02-24 at 10:48 +0200, Frank Millman wrote:
> > Hi all
> > 
> > I know that the use of 'eval' is discouraged because of the dangers of 
> > executing untrusted code.
> > 
> > Here is a variation that seems safe to me, but I could be missing something.
> > 
> > I have a class, and the class has one or more methods which accept various 
> > arguments and return a result.
> > 
> > I want to accept a method name and arguments in string form, and 'eval' it 
> > to get the result.
> > 
> > Assume I have an instance called my_inst, and a method called 'calc_area', 
> > with arguments w and h.
> > 
> > I then receive my_string  = 'calc_area(100, 200)'.
> > 
> > >>> result = eval('my_inst.{0}'.format(my_string))
> > 
> > This will only work if the string contains a valid method name with valid 
> > arguments.
> > 
> > Can anyone see anything wrong with this?
> 
> Yes.  A serious problem.
>
> 
> But actually it allows all sorts of nasty things.  Watch me open an
> arbitrary file on your system (assuming you have permission of course).
>
> >>> 
> testit('__class__.__mro__[-1].__subclasses__()[58]("/secret/file","w")')
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "", line 2, in testit
>   File "", line 1, in 
> IOError: [Errno 2] No such file or directory: '/secret/file'
> >>>

Just to elaborate a little more.  Once you've got a reference to
'object' the game it pretty much over - you can walk its subclasses to
get to all kinds of nasty things like 'file'.

Since this was a newstyle class, getting to 'object' was easy - it's
always the class's final base class (i.e. __mro__[-1]).

You might think that using an old-style class would save you:

>>> class MyClass:
... pass
... 
>>> inst = MyClass()
>>> inst.__class__.__mro__[-1]
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: class MyClass has no attribute '__mro__'


But there will almost always be a reference to a builtin type hanging
around somewhere.  Builtin types are all newstyle classes, and hence
have 'object' in their mro.  For example:

>>> inst.__dict__.__class__.__mro__[-1]

>>> 

Or perhaps:

>>> inst.__class__.__name__.__class__.__mro__[-1]



It's pretty much impossible to prevent this kind of thing in python.

You might get away with it if you parse the string looking for
suspicious characters e.g. dots.  But that will limit your grammar and I
won't be surprised if there's still a way around it.

> So please, don't do this!  :-)

So what's the alternative?  As suggested by another poster, for simple
cases use the ast.literal_eval function.

For anything more complicated, use PyParsing to generate your own mini
language and interpret it yourself.  It's really pretty simple once you
get in the right head-space.  Try some of the links from this SO post if
you want to start down this path:

   http://stackoverflow.com/questions/1545403/math-expression-evaluation



  Cheers,

 Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido rethinking removal of cmp from sort method

2011-04-04 Thread Lie Ryan
On 04/04/11 19:34, Antoon Pardon wrote:
> On Fri, Apr 01, 2011 at 10:21:33PM -0400, Terry Reedy wrote:
>>
>> rewriting cmp_to_key in C is underway
>>
>> http://bugs.python.org/issue11707
>>
> Nice to know! Any chance this wil get into 2.7.x?

Python 2.7 still have list.sort(cmp=...)/sorted(cmp=...), so cmp_to_key
is not much use there. Just pass your comparison function to the cmp
argument.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fun python 3.2 one-liner

2011-04-08 Thread Lie Ryan
On 04/06/11 01:07, Steven D'Aprano wrote:
> On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote:

> Personally, I find that the discipline of keeping to 80 characters is 
> good for me. It reduces the temptation of writing obfuscated Python one-
> liners when two lines would be better. The *only* time it is a burden is 
> when I write doc strings, and even then, only a small one.

Unless the editor I'm using has an 80-char autowrapping or a 80-char
guiding lines, I tend to wrap docstring in ~40-60 char.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Guido rethinking removal of cmp from sort method

2011-04-08 Thread Lie Ryan
On 04/09/11 01:08, Aahz wrote:
> Actually, my take is that removing __cmp__ was a mistake.  (I already
> argued about it back in python-dev before it happened, and I see little
> point rehashing it.  My reason is strictly efficiency grounds: when
> comparisons are expensive -- such as Decimal object -- __cmp__ is
> faster.)

I don't get you... why would sorting a list using __cmp__ be faster when
comparisons are expensive?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Argument of the bool function

2011-04-08 Thread Lie Ryan
On 04/09/11 08:59, candide wrote:
> Le 09/04/2011 00:03, Ethan Furman a écrit :
> 
>>  > bool([x])
>>  > Convert a value to a Boolean, using the standard truth testing
>>  > procedure.
>>  >
>>
>> As you can see, the parameter name is 'x'.
> 
> 
> OK, your response is clarifying my point ;)
> 
> 
> I didn't realize that in the bool([x]) syntax, identifier x refers to a
> "genuine" argument [I was considering x as referring to a "generic"
> object having a boolean value].
> 
> 
> Nevertheless, compare with the definition the doc provides for the
> builtin function dir():
> 
> dir([object])
> [definition omited, just observe the declaration syntax]
> 
> Now, lets make a try
> 
 dir(object="Explicit is better than implicit")
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: dir() takes no keyword arguments

> 
> Not very meaningful, isn't it ?

The error says it unambiguously, dir() does not take *keyword*
arguments; instead dir() takes *positional* argument:

dir("Explicit is better than implicit")
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
On Wed, 2011-04-13 at 17:39 -0700, rantingrick wrote:
>
> -
> 1. Poor documentation (or lack thereof):
> -
> Everyone knows that dcoumentation is important however at the end of
> the day laziness is the rule of thumb for profesionals and weekend
> teckies alike. But why be a part of any open source community and
> propagate laziness? We must be more strict about doumentation. However
> it seems the age old policies of "it's not what you know, but *who*
> you know" or more correct;y adapted tot he situation at hand..."it's
> not imprtant how well you document a module *unless* you are not a
> goodfella (psst: a memeber of Guido inc).

Oh rr, if only the time you spent formulating such eloquent prose could
be devoted instead to improving the documentation whose state you
bemoan.

I weep that your delightful rhetoric is limited to this neglected forum,
where the guardians of python core deign not to tread, and hence denied
its rightful place exalted among python's canonical lore.


> I have enlightened this group long ago of the
> limitless possibilities of IDLE to be a good primer for our budding
> young programmers however like all my great brain children this one
> has been cast aside like a red headed stepchild.

I can only imagine the hi-jinx that ensure at your yearly great brain
family reunion.


  Ryan 

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
On Thu, 2011-04-14 at 11:46 +1000, Chris Angelico wrote:
> On Thu, Apr 14, 2011 at 11:29 AM, Ryan Kelly  wrote:
> > I weep that your delightful rhetoric is limited to this neglected forum,
> > where the guardians of python core deign not to tread, and hence denied
> > its rightful place exalted among python's canonical lore.
> 
> Wait... so where do the Python experts hang out?

Don't panic, there are plenty of experts here :-)

It's an oft-cited troll complaint that many python big-wigs (Guido,
Raymond H, et al) don't subscribe to python-list.

Personally I've never really noticed - even if some of the core devs
don't really hang out here, I've always found python-list full of
helpful and knowledgeable people.

It's also an oft-cited troll conspiracy that Guido hangs out on
python-list and posts under various pseudonyms.  I think it would be
kinda fun if he did...


  Cheers,

 Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
On Wed, 2011-04-13 at 19:10 -0700, rantingrick wrote:
> On Apr 13, 8:29 pm, Ryan Kelly  wrote:
> > On Wed, 2011-04-13 at 17:39 -0700, rantingrick wrote:
> 
> I would LOVE to improve the doc, however first the student THEN the
> teacher. However in this forsaken land the "teachers" do not exist. We
> are cast off from the elites and left to wither, wandering in dark
> catacombs of source code with many doors but no keys to unlock them.
>
>  [..snip..]
>
> The "elites" have hidden themselves behind an
> impenetrable wall called python-dev. They wish not to speak with the
> peasants.

Funny you should bring that up.  The folks on python-dev are currently
making a substantial push to increase involvement in python core
development through the "Python Mentors" program.

Site here:

http://pythonmentors.com/


To quote from the site:

"""
The mission of the Python Core Mentor Program is to provide an open and
welcoming place to connect students, programmers – and anyone interested
in contributing to the Python Core development. This project is based on
the idea that the best way to welcome new people into any project is a
venue which connects them to a variety of mentors who can assist in
guiding them through the contribution process, including discussions on
lists such as python-dev, and python-ideas, the bug tracker, mercurial
questions, code reviews, etc.
"""

So anyone following along this thread, if you're interested in making a
genuine contribution to python as a language, this is a great time and
place to start.


  Ryan



-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Egos, heartlessness, and limitations

2011-04-13 Thread Ryan Kelly
On Thu, 2011-04-14 at 03:12 +, Steven D'Aprano wrote:
> On Thu, 14 Apr 2011 12:03:15 +1000, Ryan Kelly wrote:
> 
> > On Thu, 2011-04-14 at 11:46 +1000, Chris Angelico wrote:
> >> On Thu, Apr 14, 2011 at 11:29 AM, Ryan Kelly  wrote:
> >> > I weep that your delightful rhetoric is limited to this neglected
> >> > forum, where the guardians of python core deign not to tread, and
> >> > hence denied its rightful place exalted among python's canonical
> >> > lore.
> >> 
> >> Wait... so where do the Python experts hang out?
> > 
> > Don't panic, there are plenty of experts here :-)
> > 
> > It's an oft-cited troll complaint that many python big-wigs (Guido,
> > Raymond H, et al) don't subscribe to python-list.
> 
> Raymond Hettinger frequently posts here, both with interesting code 
> snippets and recipes, and to answer questions.

True.  Sorry Raymond.  You just happened to be the second name that
popped into my head in the "python big-wig" category.

> Personally, I'm glad that most of Python Dev don't hang around here. We 
> are far better off if Python Dev, you know, actually Devs Python, rather 
> than answering (mostly) easy questions and getting stuck in tar-pits.

For the record, I have no personal complaint about anyone's lack of
involvement on python-list.  Just reporting on the perceived state of
affairs.


  Cheers,

 Ryan



-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
On Fri, 2011-04-15 at 12:10 +1000, Chris Angelico wrote:
> Apologies for interrupting the vital off-topic discussion, but I have
> a real Python question to ask.
> 
> I'm doing something that needs to scan a dictionary for elements that
> have a particular beginning and a numeric tail, and turn them into a
> single list with some processing. I have a function parse_kwdlist()
> which takes a string (the dictionary's value) and returns the content
> I want out of it, so I'm wondering what the most efficient and
> Pythonic way to do this is.
> 
> My first draft looks something like this. The input dictionary is
> called dct, the output list is lst.
> 
> lst=[]
> for i in xrange(1,1000): # arbitrary top, don't like this
>   try:
> lst.append(parse_kwdlist(dct["Keyword%d"%i]))
>   except KeyError:
> break
> 
> I'm wondering two things. One, is there a way to make an xrange object
> and leave the top off? (Sounds like I'm risking the numbers
> evaporating or something.)

There is, use an infinite generator:

  def ints_from(start):
  while True:
  yield start
  start += 1


  for i in ints_from(1):
   ..etc...


But why not just put the while loop inline:

  i = 0
  while True:
  try:
  ...etc...
  except KeyError:
  break
  i += 1

It might be even easier to just iterate through the dictionary keys:

  for k in sorted(dct.keys()):
  if k.startswith("Keyword"):
  lst.append(parse_kwdlist(dct[k]))


>  And two, can the entire thing be turned
> into a list comprehension or something? Generally any construct with a
> for loop that appends to a list is begging to become a list comp, but
> I can't see how to do that when the input comes from a dictionary.

You probably could, but I think it would hurt readability in this case:

  lst = [parse_kwdlist(dct[k]) for k in sorted(dct.keys())
   if k.startswith("Keyword")]


  Cheers,

Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic infinite for loop?

2011-04-14 Thread Ryan Kelly
On Fri, 2011-04-15 at 12:34 +1000, Ryan Kelly wrote:
> On Fri, 2011-04-15 at 12:10 +1000, Chris Angelico wrote:
> >
> > 
> > My first draft looks something like this. The input dictionary is
> > called dct, the output list is lst.
> > 
> > lst=[]
> > for i in xrange(1,1000): # arbitrary top, don't like this
> >   try:
> > lst.append(parse_kwdlist(dct["Keyword%d"%i]))
> >   except KeyError:
> > break
> >
> It might be even easier to just iterate through the dictionary keys:
> 
>   for k in sorted(dct.keys()):
>   if k.startswith("Keyword"):
>   lst.append(parse_kwdlist(dct[k]))

Actually sorted() won't work here, since it sorts lexicographically.  So
you'd wind up with "Keyword111" before "Keyword2".  You would have to
sort after extracting the necessary info (assuming order is actually
important in the final list)


   Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: registrations now open

2011-04-20 Thread Ryan Kelly
Hi Everyone,


I'm pleased to announce that registrations are now open for PyCon
Australia 2011.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21.  See below for more
information and updates on:

1. Registration is now open
2. Classroom Track
3. Call For Proposals deadline approaching
4. Sponsors Announced

Please pass this message on to those you feel may be interested.



Registration Is Now Open


We offer three levels of registration for PyCon Australia 2011.
Registration provides access to two full days of technical content
presented by Python enthusiasts from around the country, as well as the
new classroom track and a seat at the conference dinner.

We are currently offering a limited number of early-bird tickets, but
get in quick because they are selling fast! 

  Corporate - $440
If your company is paying for you to attend PyCon, please register
at the corporate rate. You'll be helping to keep the conference
affordable for all.
  
  Full (Early Bird) - $165
This is the registration rate for regular attendees. We are offering
a limited Early Bird rate for the first 50 registrations until the
end of May.

  Student - $44
For students able to present a valid student card we're offering
this reduced rate, which does not include the conference dinner.

All prices include GST.  For more information or to register, please
visit the conference website.

Register here: http://pycon-au.org/reg



Classroom Track
===

In addition to the standard technical talks, this year's conference
will feature a "Classroom Track" designed specifically for tutorial
style presentations.

If you need to get up to speed on some of the latest language features
and tools, this will be a great opportunity to learn fast in a
supportive environment.



Call For Proposals
==

We've had some great initial responses to the Call For Proposals, but
there's still time left and plenty of program to fill.

Remember, the deadline for proposal submission is the 2nd of May.
That's just under two weeks away!

We are looking for proposals for talks on all aspects of Python
programming from novice to advanced levels; applications and frameworks,
or how you have been involved in introducing Python into your
organisation. We're especially interested in short presentations that
will teach conference-goers something new and useful. Can you show
attendees how to use a module? Explore a Python language feature?
Package an application?

We welcome first-time speakers; we are a community conference and we
are eager to hear about your experience. If you have friends or
colleagues who have something valuable to contribute, twist their arms
to tell us about it! Please also forward this Call for Proposals to
anyone that you feel may be interested.

The earlier you submit your proposal, the more time we will have to
review and give you feedback before the program is finalised.

Speakers receive free registration for the conference, including a seat
at the conference dinner.  Don't miss out, submit your proposal today! 

http://pycon-au.org/cfp




Sponsors Announced
==

We are happy to announce our first set of sponsors.  Thank you to the
following companies for their continuing support of Python and for
helping to make PyCon Australia 2011 a reality:


   Gold:  Google  <http://www.google.com.au/>
   Gold:  Microsoft   <http://www.microsoft.com.au/>

   Silver:  Anchor<http://anchor.com.au/>
   Silver:  Enthought <http://www.enthought.com/>
   Silver:  Python Software Foundation<http://www.python.org/psf/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.



   Ryan Kelly
   PyCon Australia 2011





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


Re: minimal python27.dll?

2011-04-27 Thread Ryan Kelly
On Wed, 2011-04-27 at 22:06 +0200, Martin v. Loewis wrote:
> Am 27.04.2011 12:43, schrieb est:
> > Hi guys,
> > 
> > I need to ship python runtime environment package on Windows, if I
> > want to stripping unnessasery functions from python27.dll to make it
> > as small as possible(and perhaps finally UPX it), which parts of
> > python27.dll do you think can be removed?
> > 
>
> I'd rather go for a static build of Python, and let the linker figure
> out what's needed.

I have vague recollections that pythonXY.dll could not be statically
linked on Windows, or that doing so causes some serious loss of
functionality.  Was this ever true, and is it still?


  Cheers,

 Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Read-write lock for Python

2011-04-28 Thread Ryan Kelly
On Thu, 2011-04-28 at 07:02 -0700, Geoff Bache wrote:
> Hi all,
> 
> I currently find myself needing a Python read-write lock. I note that
> there is none in the standard library, but googling "python read-write
> lock" quickly produced 6 different competing examples, including two
> languishing patch proposals for the standard library.
> 
> I can always pick a random one and hope for the best, but I was hoping
> someone here might have a tip for one that has been used and debugged
> and is likely to work.

I wrote and have used the "SHLock" class in threading2 which should do
what you need.  Don't know about "likely to work" but if it doesn't, I'd
like to hear about it so I can fix it :-)

  `pip install threading2`


  Cheers,

Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: cfp closing soon!

2011-04-28 Thread Ryan Kelly
Hi Everyone,


A reminder that the Call for Proposals for PyCon Australia 2011 will be
closing soon.  We've had some great proposals so far, but there is still
time left and program to fill.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:

1. Call For Proposals
2. More Sponsors Announced

Please pass this message on to those you feel may be interested.



Call For Proposals
==

The deadline for proposal submission is the 2nd of May.
That's only a few days away!

We are looking for proposals for talks on all aspects of Python
programming from novice to advanced levels; applications and frameworks,
or how you have been involved in introducing Python into your
organisation. We're especially interested in short presentations that
will teach conference-goers something new and useful. Can you show
attendees how to use a module? Explore a Python language feature?
Package an application?

We welcome first-time speakers; we are a community conference and we
are eager to hear about your experience. If you have friends or
colleagues who have something valuable to contribute, twist their arms
to tell us about it! Please also forward this Call for Proposals to
anyone that you feel may be interested.

The earlier you submit your proposal, the more time we will have to
review and give you feedback before the program is finalised.

Speakers receive free registration for the conference, including a seat
at the conference dinner.  Don't miss out, submit your proposal today! 

http://pycon-au.org/cfp



More Sponsors Announced
===

We are delighted to announce that ComOps has joined as a Gold Sponsor.
Thank you to the following companies for their continuing support of
Python and for helping to make PyCon Australia 2011 a reality:


   Gold:  Google  <http://www.google.com.au/>
   Gold:  Microsoft   <http://www.microsoft.com.au/>
   Gold:  ComOps  <http://www.comops.com.au/>

   Silver:  Anchor<http://anchor.com.au/>
   Silver:  Enthought <http://www.enthought.com/>
   Silver:  Python Software Foundation<http://www.python.org/psf/>


Thanks also to Linux Australia, who provide the overarching legal and
organisational structure for PyCon Australia.




   Ryan Kelly
   PyCon Australia 2011





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


Re: Python's super() considered super!

2011-05-27 Thread Ryan Kelly
On Fri, 2011-05-27 at 15:05 +, Duncan Booth wrote:
> sturlamolden  wrote:
> > I really don't like the Python 2 syntax of super, as it violates
> > the DRY principle: Why do I need to write super(type(self),self)
> > when super() will do? Assuming that 'self' will always be named
> > 'self' in my code, I tend to patch __builtins__.super like this:
> > 
> > import sys
> > def super():
> > self = sys._getframe().f_back.f_locals['self']
> > return __builtins__.super(type(self),self)
> > 
> > This way the nice Python 3.x syntax can be used in Python 2.x.
> > 
> > 
> Oh dear, you haven't thought this one through.
>
> ...snip...
>
> >>> C().foo()
> ... infinite recursion follows ...
> 
> Oops. There's a reason why Python 2 requires you to be explicit about 
> the class; you simply cannot work it out automatically at run time. 
> Python 3 fixes this by working it out at compile time, but for Python 2 
> there is no way around it.

Oh?  There's not much that can't be done at runtime if you're willing to
work hard enough.  Let me propose the following awful awful hack:


  import sys

  _builtin_super = __builtins__.super

  _sentinel = object()

  def _auto_super(typ=_sentinel,type_or_obj=_sentinel):
  """Automagically call correct super() at runtime"""
  #  Infer the correct call if used without arguments.
  if typ is _sentinel:
  # We'll need to do some frame hacking.
  f = sys._getframe(1)
  # Get the first positional argument of the function.
  type_or_obj = f.f_locals[f.f_code.co_varnames[0]]
  # Get the MRO for investigation
  try:
  mro = type_or_obj.__mro__
  except AttributeError:
  try:
  mro = type_or_obj.__class__.__mro__
  except AttributeError:
  raise RuntimeError("super() used with old-style class")
  #  Now, find the class owning the currently-executing method.
  for typ in mro:
  for meth in typ.__dict__.itervalues():
  if not isinstance(meth,type(_auto_super)):
  continue
  if meth.func_code is f.f_code:
  # Aha!  Found you.
  break
  else:
  continue
  break
  else:
  raise RuntimeError("super() called outside a method")
  #  Now just dispatch to builtin super.
  if type_or_obj is not _sentinel:
  return _builtin_super(typ,type_or_obj)
  return _builtin_super(typ)


Now, try is with the following:

class Base(object):
def hello(self,msg):
print "hello", msg

class Sub1(Base):
def hello(self,msg):
print "gunna say it"
super().hello(msg)

class Sub2(Base):
def hello(self,msg):
print "yes I am"
super().hello(msg)

class Diamond(Sub1,Sub2):
def hello(self,msg):
print "here we go..."
super().hello(msg)

d = Diamond()
d.hello("autosuper!")


And you get the expected output:

here we go...
gunna say it
yes I am
hello autosuper!


There may well be some cases where this breaks down, but it seems to do
the right thing in simple cases.


Not that I'm recommending anyone use this, of course...




   Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCon Australia 2011: Early Bird Closing Soon

2011-05-28 Thread Ryan Kelly

Hi Everyone,


A reminder that Early Bird Registrations for PyCon Australia 2011 will
be closing soon.  There are only a few days left to get your tickets at
the discounted rate.

PyCon Australia is Australia's only conference dedicated exclusively to
the Python programming language, and will be held at the Sydney Masonic
Center over the weekend of August 20 and 21. See below for more
information and updates on:
 
 1. Early-Bird Registration Closing Soon
 2. Presentations Selected
 3. More Sponsors Announced
 
Please pass this message on to those you feel may be interested.

 

Early-Bird Registration Closing Soon


Early-bird registration closes at the end of May, so you've only got
a few days left to get your tickets at the special discounted rate.

We offer three levels of registration for PyCon Australia 2011.
Registration provides access to two full days of technical content
presented by Python enthusiasts from around the country, as well as the
new classroom track and a seat at the conference dinner.
  
  Full (Early Bird) - $165
This is the registration rate for regular attendees. We are offering
a limited Early Bird rate for the first 50 registrations until the
end of May.

Once the early-bird period ends, Full Registration will be $198.

  Corporate - $440
If your company is paying for you to attend PyCon, please register
at the corporate rate. You'll be helping to keep the conference
affordable for all.

  Student - $44
For students able to present a valid student card we're offering
this reduced rate, which does not include the conference dinner.

All prices include GST.  For more information or to register, please
visit the conference website.

Register here: http://pycon-au.org/reg



Presentations Selected
==

We have had a fantastic response to our Call For Proposals this year.
While the detailed talk schedule is still being finalised, we are
pleased to announce that the following presentations have been selected
for the conference:

  Standard Talks:

A Python on the Couch  (Mark Rees)
Behaviour Driven Development  (Malcolm Tredinnick)
Benchmarking stuff made ridiculously easy  (Tennessee Leeuwenburg)
Bytecode: What, Why, and How to Hack it  (Ryan Kelly)
Developing Scientific Software in Python  (Duncan Gray)
Fun with App Engine 1.5.0  (Greg Darke)
Hosting Python Web Applications  (Graham Dumpleton)
How Python Evolves (and How You Can Help Make It Happen)  (Nick Coghlan)
Infinite 8-bit Platformer  (Chris McCormick)
Networking Libraries in Python.  (Senthil Kumaran)
Pants - Network Programming Made Easy  (Evan Davis)
Say What You Mean: Meta-Programming a Declarative API  (Ryan Kelly)
State of CPython and Python Ecosystem  (Senthil Kumaran)
Sysadmins vs Developers, a take from the other side of the fence  (Benjamin 
Smith)
Teaching Python to the young and impressionable  (Katie Bell)
The NCSS Challenge: teaching programming via automated testing  (Tim 
Dawborn)
Weather field warping using Python.  (Nathan Faggian)
Zookeepr: Home-grown conference management software  (Brianna Laugher)

  In-Depth Talks:

Ah! I see you have the machine that goes "BING"!  (Graeme Cross)
Easy site migration using Diazo and Funnelweb  (Adam Terrey)
How to maintain big app stacks without losing your mind  (Dylan Jay)
Introduction to the Geospatial Web with GeoDjango  (Javier Candeira)
Panel: Python 3  (Richard Jones)
Panel: Python in the webs  (Richard Jones)
Pyramid: Lighter, faster, better web apps  (Dylan Jay)
Web micro-framework battle  (Richard Jones)

  Classroom Track:

Meta-matters: using decorators for better Python programming  (Graeme Cross)
Python 101+  (Peter Lovett)
Python's dark corners - the bad bits in Python and how to avoid them  
(Peter Lovett)
Python for Science and Engineering, Part 1  (Edward Schofield)
Python for Science and Engineering, Part 2  (Edward Schofield)
The Zen of Python  (Richard Jones)


Thanks again to everyone who submitted a proposal.


 
More Sponsors Announced
===

We are delighted to announce that WingWare and Superior Recruitment have
joined as Silver Sponsors.  Thank you to the following companies for
their continuing support of Python and for helping to make PyCon
Australia 2011 a reality:

Gold:  Google  <http://www.google.com.au/>
Gold:  ComOps  <http://www.comops.com.au/>
 
Silver:  Anchor<http://anchor.com.au/>
Silver:  Enthought <http://www.enthought.com/>
Silver:  Python Software Foundation<http://www.python.org/psf/>
Silver:  WingWare  <http://www.wingware.com/>
Silver:  Superior Recruitmen

How to track usage within a desktop python application

2017-10-08 Thread Ryan Holmes
I maintain a desktop python application that is used by a decent number of 
folks (I would assume 10k+, though it's hard to know since it's based on number 
of downloads rather than number of unique users). I would like to integrate 
some sort of usage tracking that would enable me to determine number of users 
along with startups, which features are used/not used, performance metrics, 
exceptions, etc. Since it's an open-source project, I am looking for a free 
service (or a service that provides free licenses to open source projects) that 
has a python client library. 

Can anyone recommend something?
-- 
https://mail.python.org/mailman/listinfo/python-list


FW: Printing to a file and a terminal at the same time

2017-10-12 Thread Lie Ryan
It wouldn't be too difficult to write a file object wrapper that emulates tee, 
for instance (untested):

class tee(object):
def __init__(self, file_objs, autoflush=True):
self._files = file_objs
self._autoflush = autoflush

def write(self, buf):
for f in self._files:
f.write(buf)
if self._autoflush:
self.flush()

def flush(self):
for f in self._files:
f.flush()

use like so:

sys.stdout = tee([sys.stdout, open("myfile.txt", "a")])


Another approach is by bsandrow (https://github.com/bsandrow/pytee), which uses 
fork and os.pipe(), this more closely resembles what the actual tee command are 
actually doing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Questions on PEP 440 - Version Identification and Dependency Specification

2018-08-18 Thread Ryan Holmes
Greetings all,

I currently follow PEP 440 as it relates to my application. Right now we follow 
a x.y.z scheme, with y incrementing with our normal releases, z incrementing 
for any bug fixes for that release, and x not really incrementing unless 
something major happens (for example, our conversion from python 2 to 3)

Our current release is v2.3.1. For the past several weeks, I've been working on 
a significant overhaul to one of our systems which also includes a variety of 
new features, and I now want to create a beta release for this so that folks 
can start testing it. 

Normal convention would be to version it v2.4.0b1, however I don't actually 
know if v2.4.0 will contain this refactoring / featureset (our releases are 
also tied to a third party, so if they release an update, we do too, so we 
don't have much control over the timing of our releases; so things like this 
might be delayed until 2.5.0, for example), so it would seem odd saying that 
this is a beta of 2.4.0 if 2.4.0 might not ultimately contain it. I just don't 
yet know which version this is being planned for.

I'm aware that I'm probably overthinking this, but was just curious to see what 
those in the community might think as well. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


pip hangs after successful operation

2018-10-04 Thread Ryan Johnson
Hello, I am seeking some quick help, and probably am reporting bugs along the 
way. I apologize that this is a long email. Please let me know what I should do 
in the future.

On Windows, pip hangs and does not install packages in the proper location (or 
perhaps, at all), even if pip claims it installed successfully. Upon hanging, I 
can use Ctrl+C to terminate individual processes that have succeeded, and the 
results show up in “pip list”, but this bug affects any packages that call pip 
within their install script, which makes this a critical bug, since the package 
install scripts will never complete.

Filed bug report here: https://github.com/pypa/pip/issues/5850

My environment:
➢ Python 3.7.0 x64
➢ pip 18.0
➢ Windows 10 Pro x64

Steps taken to resolve, so far:
➢ Repaired Installation.
➢ Removed and Reinstalled Installation.
➢ Rebooted computer as last resort.

This appears to be a bug similar to https://github.com/pypa/pip/issues/4588 

However, unlike in that bug report, pip hangs after all of these commands:
• pip list
• pip install
• pip install --upgrade pip

However, when called using “py -m pip”, these commands do not hang, and, upon 
inspection of the package list, via “pip list” and “py -m pip list” methods, 
there is a discrepancy. This is the culprit, but I don’t know how to fix the 
problem. Output:

• PS C:\Users\Ryan> py -V
Python 3.7.0

• PS C:\Users\Ryan> pip list
Package Version
--- ---
Click   7.0
mysqlclient 1.3.13
pip 18.0
pip-tools   3.0.0
setuptools  40.4.3
six 1.11.0

• PS C:\Users\Ryan> py -m pip list
Package    Version
-- ---
pip    18.0
setuptools 40.4.3

Notice the package lists are different. The outputs above are from the exact 
same pip executable:

• PS C:\Users\Ryan> pip -V
pip 18.0 from 
c:\users\ryan\appdata\local\programs\python\python37\lib\site-packages\pip 
(python 3.7)

• PS C:\Users\Ryan> py -m pip -V
pip 18.0 from 
C:\Users\Ryan\AppData\Local\Programs\Python\Python37\lib\site-packages\pip 
(python 3.7)

I have another machine running Python 3.7.0 x64 that does not experience this 
issue.

Both machines have the same set-up:
➢ Python 3.7.0 from x64 installer (local user install, not All Users install, 
with PATH option checked. pip runs directly in terminal.)
➢ Python 3.6.6 from Visual Studio 2017 installer (pip does not run unless 
called from py -m pip or py -3.6 m pip)
➢ Anaconda from installer (not used yet)
➢ MySQL Connector Python 8.0.12 from MySQL Installer (only installs for Python 
3.6.6, not compatible with Python 3.7.0)
➢ Cygwin
➢ MinGW/MSYS

I have exhausted all online help documentation, and none of the bug reports 
contain answers that explain why one computer fails while the other does not.

Further testing reveals more bugs:

This bug does not affect the older Python 3.6.6 pip on either machine:

• py -3.6 -m pip -V
pip 10.0.1 from < blah path to Python36_64 package dir >

• py -3.6 -m pip install matplotlib
MySQL-connector-python 8.0.12 requires protobuf>=3.0.0, which is not installed.

The installation [also] fails, but at least it doesn’t hang.
However it is not possible to install protobuf, as this also fails:

• py -3.6 -m pip install protobuf
Could not install packages due to an EnvironmentError: [Errno 13] Permission 
denied: C:\\ ….. \\six.py

And it cannot upgrade:

• py -3.6 -m pip install --upgrade pip
Could not install packages due to an EnvironmentError: [WinError 5] Access is 
denied: ‘c:\\program...\\...\\pip-10.0.1.dist-info\\entry_points.txt’
Consider using the `--user` option or check the permissions.

Used the suggestion, which looked more like a warning:

• Py -3.6 -m pip install --upgrade pip --user
Successfully installed

Permission denied is a bad excuse to fail, when a command line argument can 
change this. I do not like adding command line switches to something that 
should work without them (since I specifically call this user-specific resource 
in the command statement), because there is no telling what the application 
will do from a black-box engineering viewpoint. This error message / hint 
should be more elaborate, explaining what the switch does, as it is 
counterintuitive for anyone familiar with Linux to believe for one second that 
“--user” is supposed get around a “permission denied” problem by elevating 
permissions, after years of telling users they need to use “sudo” to run 
something as root. This is an advantage for the ignorant coder. If ignorance is 
an advantage, then that just means the error message is not explanative enough. 
Requiring users to glean the meaning of “—user” from the “—help” option wastes 
time and mental resources by adding another layer of complexity to the 
installation process. It is not obvious that there is a “–help” option for “pip 
install” (hence the waste of time).

Other bug encountered recently:

Also, there is a bug that I reported approximately a week ago with the 
mysqlclient package instal

Solved: pip hangs after successful operation (sandboxed environment problem)

2018-10-05 Thread Ryan Johnson
It turns out that Comodo Antivirus auto-sandboxes any program that it doesn’t 
recognize, and this included python in the C:\Users\$user\AppData\Programs 
directory.

This also affects Cygwin and MSYS2 (but not MSYS).

If you are thinking about using Comodo, disable the Auto-Containment feature. 
Alternately, you may try to add the folder locations to the white-list, but 
this didn’t work for me.

Have a nice day,
Ryan

Sent from Mail for Windows 10

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


Re: Python indentation (3 spaces)

2018-10-05 Thread Ryan Johnson
The point that OP is trying to make is that a fixed standard that is
distinguishable from the even-spacing Tab-length convention in code and
text editors will establish a level of trust between the end developer and
upstream developers or co-developers who may not have the same development
environment. For example, the first Python library I ever tried to use was
poorly maintained and had spaces on one line with tabs on the next, and the
author mixed naming conventions and syntax from Python 2 and 3 in his code.
That type of experience doesn’t exactly instill trust in the coding
language’s standards, when a noob tries to use a library they found and
ends up having to debug weird errors with weirder error messages on the
first project they do.

Flexibility is great until the learning curve comes into play. That said,
there is an easy fix for tab misuse: in Visual Studio Code, you can replace
all Tabs with Spaces by highlighting the entire code block, hitting Tab
once and Shift-Tab after.

Peace
Ryan
On Fri, Oct 5, 2018 at 4:51 PM Terry Reedy  wrote:

> On 10/5/2018 4:48 PM, ts9...@gmail.com wrote:
> > I am new to Python programming but have significant SQL and C
> experience. My simple question is,"Why not standardize Python indentations
> to 3 spaces instead of 4 in order to avoid potential programming errors
> associated with using "TAB" instead of 4 spaces?"
>
> IDLE (and other modern editors and IDEs) turns a typed TAB into a
> user-settable n spaces, where n defaults to 4 (minimum 2, maximum 16).
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Ryan Johnson
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python indentation (3 spaces)

2018-10-07 Thread Ryan Johnson
> What library? From where?

It was a GitHub repository for a zebra scanner (barcode scanner) module (and 
sorry for calling it a library; I don’t recall if it was a library or module).

The logic is that all the text editors that are designed to work with Python 
code will KNOW to replace tab input with 3 characters, while still parsing the 
\t tab character as 4 characters; while the editors that aren’t made for python 
input are generally older or non-coding text editors that maintain the older 
Tab convention that looks like 4 spaces, so it is visually distinguishable, 
when loading code that a person made on one of these non-python-aware text 
editors.

The difference we want to see is that Python-aware creates 3 spaces from the 
keyboard, while still displaying 4 spaces on parsing \t . If this becomes a 
coding convention for Python, it’ll be enforced by editors that are intended to 
be used with Python (i.e. the ones that currently replace `Tab` keyboard input 
with 4 characters).

It’s slick. And annoying, because every OCD person in the room is going to 
choke when they see 3 characters for a tab.

> If someone violates a law, does that make the law bad? And if people follow a 
> law, does that make it good?

No, the question you should ask is “if the current law causes an unintended 
ambiguity or side-effect, could there be a more clear law that makes the 
ambiguity go away?” Clearly the current law wasn’t up to the task of 
delineating 1: bad code from a bad editor opened in a good editor, and 2: good 
code from a good editor opened in a good editor or bad editor.

The distinction can be made known to the good programmer by having the good 
editors follow a convention that makes the difference evident, while a bad 
editor continues to show no distinction between good and bad code. Remember, 
the primary rule is that a good editor will obviously not permit a bad coder to 
type bad spacing, but a bad editor will.

This convention change would allow a person using a good editor to know that 
the code was made in a non-python-oriented editor immediately, instead of 
blowing up their debug console with Syntax errors.

If I was less than accurate in my explanation, I apologize, but the concept 
itself is solid, except for the annoyance of being an odd number of spaces.


Sent from Mail for Windows 10

From: Terry Reedy
Sent: Sunday, October 7, 2018 10:35 AM
To: python-list@python.org
Subject: Re: Python indentation (3 spaces)

On 10/5/2018 11:30 PM, Ryan Johnson wrote:
> The point that OP is trying to make is that a fixed standard that is
> distinguishable from the even-spacing Tab-length convention in code and
> text editors will establish a level of trust between the end developer and
> upstream developers or co-developers who may not have the same development
> environment.

And my counter point is that a) we will not change the standard and b) 
we deliver an editor that by default enforces the standard, and c) to be 
fair, many other editors will do the same.

> For example, the first Python library I ever tried to use was

What library?  From where?

> poorly maintained and had spaces on one line with tabs on the next, and the
> author mixed naming conventions and syntax from Python 2 and 3 in his code.
> That type of experience doesn’t exactly instill trust in the coding
> language’s standards, when a noob tries to use a library they found and
> ends up having to debug weird errors with weirder error messages on the
> first project they do.

I don't follow the logic.  If someone violates a law, does that make the 
law bad?  And if people follow a law, does that make it good?

People obviously should not distribute buggy messes, at least not 
without warning.  Were you using the library with an unsupported 
version?  Or inform the author or distributor?

> Flexibility is great until the learning curve comes into play. That said,
> there is an easy fix for tab misuse: in Visual Studio Code, you can replace
> all Tabs with Spaces by highlighting the entire code block, hitting Tab
> once and Shift-Tab after.

IDLE does that also.

-- 
Terry Jan Reedy


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

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


Re: Python doesn't install

2018-10-10 Thread Ryan Johnson
Need more info than that. For a problem as unusual as that, it'll take a
lot of scrutiny to find the problem.
Dump as much info as you can about your system environment and your
existing installations and upload them to https://hastebin.com/  (secure
and private text host).
Include relevant screenshots via Imgur.com and add to a private album (for
access by link only).
Windows eventually needs reinstalling, even in 2018. Sad really.

On Wed, Oct 10, 2018 at 1:12 PM Daan Kahmann 
wrote:

> Op woensdag 10 oktober 2018 19:20:42 UTC+2 schreef Terry Reedy:
> > On 10/10/2018 9:53 AM, daankahman...@gmail.com wrote:
> >
> > > I have an annoying problem, I can download Python (from python.org)
> but it won't install on my laptop. If I try to open the installer, it
> closes again. I also don't get a error message. I'm using windows 10. I
> already tried most of the obvious things like restarting, deleting the
> program and downloading it again and I tried windows problem solver from
> tweaking.com. But nothing seems to work. Does anyone know how I might be
> able to fix this?
> >
> > Which exact binary?  Have you tried other versions?  Have you installed
> > Python before?
> >
> > --
> > Terry Jan Reedy
>
> version 3.7.0, I have tried installing other versions but I get the same
> problem. I have not installed Python on this laptop before.
>
> Daan Kahmann
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

If you believe in an open internet, and that you should be free to fix your
own computer and program and modify it without restrictions, join the Free
Software Foundation
<https://my.fsf.org/associate/support_freedom/join_fsf?referrer=9448> and
the Electronic Frontier Foundation <https://www.eff.org/>. They protect
your digital rights.


Ryan Everett Johnson
-- 
https://mail.python.org/mailman/listinfo/python-list


Single DB connection during class's lifetime. Metaclass, singleton and __new__() examples and references.

2018-10-11 Thread Ryan Johnson
I am working on using mysql.connector in a class and have found an example of 
how to create a single connection that spans the lifetime of all instances of 
the class:

https://softwareengineering.stackexchange.com/a/358061/317228 

however, I do not understand a few things about the class, including

1. Why it is subclassed as an object: `class Postgres(object):` ? I thought 
classes were necessarily objects.
2. Why is this portion of code directly addressing the class, instead of using 
the `cls` reference variable?
connection = Postgres._instance.connection = psycopg2.connect(**db_config)
cursor = Postgres._instance.cursor = connection.cursor()
3. And is it me or does anyone else think {anydb}.connector’s usage is messy 
and inelegant? Ex:
print('connecting to PostgreSQL database...')
connection = Postgres._instance.connection = psycopg2.connect(**db_config)
cursor = Postgres._instance.cursor = connection.cursor()
cursor.execute('SELECT VERSION()')
db_version = cursor.fetchone()
Why can’t we associate the focus of the connection with the connection 
itself, instead of creating a separate cursor object?

Also, within the code example, and in Python in general, why does there needs 
to be a __new__ constructor when there’s an __init__ constructor? I’ve read 
about the usage of singletons. It seems you could create singletons within  
__init__ or __new__ . Any enlightenment would be really helpful. I am very 
sleep-deprived, so I’m sorry if this seems like a dumb question.

I have read the official docs. Have also been reading “Python 3: Patterns, 
Recipes, and Idioms”. The first was mildly helpful but I still don’t see the 
benefit of a __new__ constructor.
Why is there dislike for Metaclasses?

Thanks, and I’ll have better incisive questions in the future.

Sent from Mail for Windows 10

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


RE: Single DB connection during class's lifetime. Metaclass,singleton and __new__() examples and references.

2018-10-12 Thread Ryan Johnson
Thanks for the clarification.

If I am creating a class variable, are you suggesting I perform the “if it 
exists, great, otherwise make it” logic in the __init__ block or in the class 
definition block? Will that even run in a class definition? I never see 
examples do anything besides assignment operations and flow control, although 
it would follow that if the block allows creation of strings (an object), it 
would allow creation of connection objects. On the other hand, the __init__ 
block seems like a natural place to put the cursor instantiation.

From this answer ( 
https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642
 ) the pythonic way to access the class variable is using type(self), but 
doesn’t this access the local class’s variable, if someone subclasses my class? 
Can I specify my class variable via the class name itself? Example: instancevar 
= ClassName.classvar .
I am hoping that because of the way python points labels to objects, this 
should give my instance an instance var that refers to the class var. Am I 
right?

RJ

Sent from Mail for Windows 10

From: Thomas Jollans
Sent: Friday, October 12, 2018 2:05 AM
To: python-list@python.org
Subject: Re: Single DB connection during class's lifetime. Metaclass,singleton 
and __new__() examples and references.

On 12/10/2018 01:19, Ryan Johnson wrote:
> I am working on using mysql.connector in a class and have found an example of 
> how to create a single connection that spans the lifetime of all instances of 
> the class:
> 
> https://softwareengineering.stackexchange.com/a/358061/317228
> 
> however, I do not understand a few things about the class, including
> 
> 1. Why it is subclassed as an object: `class Postgres(object):` ? I thought 
> classes were necessarily objects.

This was sometimes necessary in Python 2.

> 2. Why is this portion of code directly addressing the class, instead of 
> using the `cls` reference variable?
> connection = Postgres._instance.connection = psycopg2.connect(**db_config)
> cursor = Postgres._instance.cursor = connection.cursor()

In a subclass, the `cls' argument would refer to the subclass, while 
`Postgres' would still refer to the original class. I have no idea what 
this is trying to achieve, and I think it's probably a bug. Maybe 
someone else has an idea.

> 3. And is it me or does anyone else think {anydb}.connector’s usage is messy 
> and inelegant? Ex:
> print('connecting to PostgreSQL database...')
> connection = Postgres._instance.connection = psycopg2.connect(**db_config)
> cursor = Postgres._instance.cursor = connection.cursor()
> cursor.execute('SELECT VERSION()')
> db_version = cursor.fetchone()
>   Why can’t we associate the focus of the connection with the connection 
> itself, instead of creating a separate cursor object?

You can have multiple cursors on the same connection.

> 
> Also, within the code example, and in Python in general, why does there needs 
> to be a __new__ constructor when there’s an __init__ constructor? I’ve read 
> about the usage of singletons. It seems you could create singletons within  
> __init__ or __new__ . Any enlightenment would be really helpful. I am very 
> sleep-deprived, so I’m sorry if this seems like a dumb question.
> 
> I have read the official docs. Have also been reading “Python 3: Patterns, 
> Recipes, and Idioms”. The first was mildly helpful but I still don’t see the 
> benefit of a __new__ constructor.

You can't create a singleton with __init__: by the time __init__ is 
called, a new instance has already been created, and you can't switch 
the object for a different one. By using __new__, you can bypass the 
creation of a new instance.

If what you want is some shared state between all instances, a class 
variable or global will do just fine and there's no need for a singleton 
instance of anything.

> Why is there dislike for Metaclasses?

They can be confusing.

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

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


RE: Single DB connection during class's lifetime. Metaclass,singletonand __new__() examples and references.

2018-10-15 Thread Ryan Johnson
Thank you. That clears everything up.

Sent from Mail for Windows 10

From: Cameron Simpson
Sent: Saturday, October 13, 2018 6:06 PM
To: Ryan Johnson
Cc: python-list@python.org
Subject: Re: Single DB connection during class's lifetime. 
Metaclass,singletonand __new__() examples and references.

On 12Oct2018 13:28, Ryan Johnson  wrote:
>Thanks for the clarification.
>
>If I am creating a class variable, are you suggesting I perform the “if it 
>exists, great, otherwise make it” logic in the __init__ block or in the class 
>definition block? Will that even run in a class definition?

The class definition code runs when the class is defined (as Python 
reads it in your code).

The __init__ block runs once each time a new instance of the class is 
initialised.

When do you _want_ this logic to run? That dictates where the logic 
goes.

If you run this in the class definition code it pretty much will 
unconditionally make a db connection. But in reality (a) you usually 
want to defer making the connection until you need it to reduce resource 
usage and (b) you often don't know enough to make the connection at 
class definition time i.e. you don't know the database host, the 
credentials, etc - they are often supplied to the initialiser (directly 
or via some config file).

>I never see examples do anything besides assignment operations and flow 
>control, although it would follow that if the block allows creation of 
>strings (an object), it would allow creation of connection objects. On 
>the other hand, the __init__ block seems like a natural place to put 
>the cursor instantiation.

You can do anything that is sensible in the __init__ block - it is just 
code. Your goal is to decide what is sensible.

Normally the initialiser mosts sets up various arrtributes to sane 
initial values. It can do complex things, but is usually relatively 
basic.

I'd note, as Thomas did, that the cursor is a control object associated 
with a query. You can have multiple cursors on a connection, and you 
often make one from a query, process the query results, then discard the 
cursor. SO you routinely use several during the lifetime of a 
connection.

Therefore you don't make cursors when you set up the connection; you 
make them in association with queries.

>From this answer ( 
>https://stackoverflow.com/questions/25577578/python-access-class-variable-from-instance/25577642#25577642
> ) the pythonic way to access the class variable is using type(self), but 
>doesn’t this access the local class’s variable, if someone subclasses my 
>class? Can I specify my class variable via the class name itself? Example: 
>instancevar = ClassName.classvar .
>I am hoping that because of the way python points labels to objects, this 
>should give my instance an instance var that refers to the class var. Am I 
>right?

_Usually_ I access class attributes (which you're calling variables, I 
believe - they're not) via the instance:

  def foo(self, blah=None):
if blah is None:
  blah = foo.DEFAULT_BLAH_VALUE
... work with blah ...

As you suggest, this will find DEFAULT_BLAH_VALUE from the subclass 
before it finds it from the superclass. Usually that is what I want - 
the purpose of subclassing is to (possibly) override the aspects of the 
superclass.

However, you _can_ always reach directly to a specific class to get a 
value:

  blah = MySuperCLass.DEFAULT_BLAH_VALUE

if that is sensible. All you're doing is changing the way in which the 
name "DEFAULT_BLAH_VALUE" is found: do I use the instance's name lookup 
or go somewhere direct?

In your case with a persistent database connection associated with a 
class it would be best to make the "get a connection" logic a class 
method because the "is there a connection" attribute is associated with 
the class, not the instance.

Methods are, by default, "instance" methods: they are defined like this:

  def method(self, ...):

and you largely work through "self", being the current instance. That is 
its "context".

Class method are defined like this:

  @classmethod
  def method(cls, ...)

and instead of having an instance as context (with the conventional name 
'self"), you have the class (with the conventional name "cls"). These 
are for methods which _do_ _not_ care about the instance, just the 
class. So in the case of your database connection, made on demand once 
per class, you might go:

  @classmethod
  def conn(cls):
c = cls.connection
if c is None:
  c = connect_to_the_db(.)
  cls.connection = c
return c

See that there's no "self" in here?

Then your instance methods can look like this:

  def lookup(self, ):
conn = self.conn()
cursor = conn.select()
... use the cursor to process the result ...

The instance finds the "conn"

RE: Wikipedia on Python

2018-10-16 Thread Ryan Johnson
Not really having read the whole story here, just wanna say that Wikipedia 
articles already suffer from a tug-of-war between professionals and students. 
Don’t worsen the problem. Include lay explanation and go into the technical 
details in a natural progression. Don’t force the reader to make large 
perspective jumps or conceptual jumps or require them to approach the article 
from the perspective of the designer from one sentence to the next. Pick your 
audience first, then write. Wikipedia requires a bridge between student and 
professional. Write it like it’s a synopsis that goes into detail, not like a 
reference manual for the already-initiated reader. If you like to write like 
it’s a reference, then there are list metapages on Wikipedia that tend to be 
agreeable to this.

peace

Sent from Mail for Windows 10

From: Spencer Graves
Sent: Tuesday, October 16, 2018 1:06 PM
To: Léo El Amri; python-list@python.org
Subject: Wikipedia on Python

   Thanks to Léo El Amri and Thomas Jollans for their quick and 
helpful replies to my question about "Package creation documentation".


   Beyond that, I'd like to encourage people on this list to review 
the Wikipedia article on "Python (programming language)",[1] especially 
the claim that "a package is a Python module with an __path__ 
attribute", which I added on 2018-09-24 to help me understand the 
distinction.


   That Wikipedia article has averaged over 6,000 views per day over 
the past 3 years.  Therefore, any improvements will benefit lots of people.


   If you have suggestions for how the article might be improved, 
you can post them to the "Talk" page associated with that article or 
send them to me.  If you are "autoconfirmed" with the Wikimedia system, 
you can make the changes yourself.


   Thanks,
   Spencer Graves


[1] https://en.wikipedia.org/wiki/Python_(programming_language)


On 2018-10-16 11:14, Léo El Amri wrote:
> Hello Spencer,
>
> On 16/10/2018 17:15, Spencer Graves wrote:
>>Where can I find a reasonable tutorial on how to create a Python
>> package?
> IMO, the best documentation about this is the tutorial:
> https://docs.python.org/3/tutorial/modules.html#packages
>
>>According to the Python 3 Glossary, "a package is a Python module
>> with an __path__ attribute."[1]
> What you are looking at are the technical details of what a package is.
> Incidentally, if you follow the tutorial, everything will get in-place.
>
>>I found "packaging.python.org", which recommends "Packaging Python
>> Projects"[2] and "An Overview of Packaging for Python".[3]
> packaging.python.org is centered on "How to install and distribute
> Python packages (Or modules)"
>
> - Léo
>

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

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


RE: ESR "Waning of Python" post

2018-10-16 Thread Ryan Johnson
Have seen this waning of python thread so many times. Hoping it would have 
waned by now. Lol.

Sent from Mail for Windows 10

From: jfine2...@gmail.com
Sent: Tuesday, October 16, 2018 12:42 PM
To: python-list@python.org
Subject: Re: ESR "Waning of Python" post

On Tuesday, October 16, 2018 at 8:00:26 AM UTC+1, Marko Rauhamaa wrote:
>https://making.pusher.com/golangs-real-time-gc-in-theory-and-practice/>

I'm all in favour of collecting useful URLs. Here's some more suggestions:

https://stackoverflow.com/questions/4491260/explanation-of-azuls-pauseless-garbage-collector
https://pdfs.semanticscholar.org/9770/fc9baf0f2b6c7521f00958973657bf03337d.pdf
https://www.researchgate.net/publication/220800769_Tax-and-spend_Democratic_scheduling_for_real-time_garbage_collection
http://digg.com/2018/private-garbage-collection-propublica
http://flyingfrogblog.blogspot.com/

Aside: One of the above is not about software garbage collection. Can you guess 
which one?

-- 
Jonathan




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

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


Advice on law firm

2018-10-17 Thread Ryan Johnson
Anyone know a good US based law firm that specializes in software licenses and 
class action suits?

Sent from Mail for Windows 10

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


RE: Advice on law firm

2018-10-17 Thread Ryan Johnson
Correction: specializing in warranty of merchantability, software licenses, and 
possibly class action suits.

Sent from Mail for Windows 10

From: Ryan Johnson
Sent: Wednesday, October 17, 2018 9:26 PM
To: python-list@python.org
Subject: Advice on law firm

Anyone know a good US based law firm that specializes in software licenses and 
class action suits?

Sent from Mail for Windows 10


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


RE: email automation

2018-10-23 Thread Ryan Johnson
Consider a web service API…Not really sure about where you want to evaluate 
your incoming emails, but perhaps MailChimp could help.
https://mailchimp.com/features/marketing-automation/
There are a bunch of ways to automate things with web services now, using 
Zapier.

https://mailchimp.com/features/marketing-automation/ 

Your question opens a big pandora’s box.

If you use web svc with API, either expect them to provide a library in your 
language, or expect them to send a structured data file over the internet, like 
json.
For web connection, use urllib.
For json use json module.
On windows:
py -m pip install urllib json

Sent from Mail for Windows 10

From: Brian Oney via Python-list
Sent: Monday, October 22, 2018 11:37 AM
To: python-list@python.org
Subject: email automation

Dear List,

I would like to send out custom automated replies to email. In the future, I
would like to be able to integrate nltk and fuzzy matching if necessary.

After some basic research I have a few options:

 1. Grapple with OpenEMM (interesting software, has python library, still 
alive and kicking, a bit overkill for my use-case);
 2. build on the examples in 'Automate the boring stuff';
 3. forget about it.
 
Please tell me about any possible alternatives I missed.

Kind regards,
Brian
-- 
https://mail.python.org/mailman/listinfo/python-list

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


Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-06 Thread Lie Ryan
> I like to step through my code line by line,
> it's impossible to do it with
> object-oriented programming language.

I suggest pudb, it's a curses based debugger, which is nicer than pdb, but 
doesn't require tedious IDE setup.

> Also, there's no good REPL IDE. 

Not quite sure what you meant by REPL IDE, but did you try IPython
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Scons-users] SCons Version 3.0.3 Released

2019-01-08 Thread Ryan Schmidt



On Jan 7, 2019, at 21:26, Bill Deegan wrote:

>   A new SCons release, 3.0.3, is now available on the SCons download page:
> 
>   https://scons.org/pages/download.html
> 
> 
>   Here is a summary of the changes since 3.0.1:

It would have been good to mention the changes since 3.0.2, which are:


RELEASE 3.0.3 - Mon, 07 Jan 2019 20:05:22 -0400
  NOTE: 3.0.2 release was dropped because there was a packaging bug. Please 
consider all 3.0.2
content.

  From William Deegan:

- Fixes to packaging logic.  Ensuring the SCons.Tool.clangCommon module is 
added
  to the release packages.
- Modify scons.bat script to check for scons python script without .py 
extension if no file
  scons.py exists. This enables an all platform wheel to work.

  From Mats Wichmann:
- Update doc examples to work with Python 3.5+:  map() now returns an 
iterable instead of a list.


See https://github.com/SCons/scons/blob/rel_3.0.3/src/CHANGES.txt

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


Can't run program

2020-05-19 Thread Ryan Harrington
Hi - I'm not the least bit technical. Trying to learn through YouTube. I've
gotten exit code 1, 2, 106. Tried setting up the project interpreter and
can't figure it out. Tried uninstalling and reinstalling everything and
still having problems. Any feedback appreciated.

Thank you,
--

Ryan Harrington
Director of Sales
M - 860-303-2265
WhiteSourceSoftware.com <https://www.whitesourcesoftware.com/>
Boston, MA, USA
-- 
https://mail.python.org/mailman/listinfo/python-list


shelve object back to dictionary

2005-10-06 Thread Ryan Krauss
Is there an easy way to convert a shelved object back to a dictionary?
 When I save a dictionary using shelve and then load it in a later
session, I have an object whose property names are the keys of the
dictionary used as an input to shelve.  For example, instead of
user['name'] I have user.name.  I would prefer to have the scripts I
write to analyze the saved data have a similar syntax to the ones I
used to create it, so I would rather deal with a dictionary after I
load the shelved data.

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


passing variable arguments to a function

2005-10-13 Thread Ryan Wilcox
Hello all,

I want to be able to pass a variable number of parameters into a Python
function. Now, I know how to _receive_ variable arguments, but I don't
know how to _send_ them.

def myFunction(*args):
print args

myList = [1, 2, 3, 4]
myFunction(myList)

this function will print out ([1, 2, 3, 4]).

Except that's not what I want. I want the equivalent to:

myFunction(1, 2, 3, 4)

So, given an array, how can I unpack the array and pass all of the
elements into a Python function as parameters?

Thanks in advance!,
_Ryan Wilcox

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


Re: finding name of instances created

2005-01-24 Thread Ryan Paul
On Mon, 24 Jan 2005 13:19:45 +, Ryan Paul wrote:

> 
> A working solution:
> 
> class A:
>   pass
> 
> a = A()
> b = A()
> c = A()
> 
> [x for x,y in locals().items() if
>   hasattr(y,"__class__") and y.__class__ == A]
> 

Just wanted to clarify, because I know that the intellectually deficient
amongst you will say that isinstance is better than using __class__...

In this case isinstance isnt desirable because it will catch
instances of any objects that inherit A, not just instances of A. Observe:

class A: pass
class B(A): pass

a = A()
b = A()
c = A()
d = B()

>>> [x for x,y in locals().items() if isinstance(y,A)]
['a', 'c', 'b', 'd']

>>> [x for x,y in locals().items() if
... hasattr(y,"__class__") and y.__class__ == A]
['a', 'c', 'b']

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


Re: finding name of instances created

2005-01-24 Thread Ryan Paul
On Fri, 21 Jan 2005 16:13:19 -0800, André wrote:

> Short version of what I am looking for:
> 
> Given a class "public_class" which is instantiated a few times e.g.
> 
> a = public_class()
> b = public_class()
> c = public_class()
> 
> I would like to find out the name of the instances so that I could
> create a list of them e.g.
> ['a', 'b', 'c']
> 


A working solution:

class A:
  pass

a = A()
b = A()
c = A()

[x for x,y in locals().items() if
  hasattr(y,"__class__") and y.__class__ == A]

That said, you probably dont want to do it. I doubt that it will work
consistently.

BTW, based on my understanding of the other stuff you said, this is
probably not the best way to do whatever it is you are trying to do.

--SegPhault




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


Re: What is print? A function?

2005-01-24 Thread Ryan Paul
On Sun, 23 Jan 2005 18:01:50 +, Frans Englich wrote:

> 
> Nah, I don't think it's a function, but rather a builtin "statement". But
> it's  possible to invoke it as an function; print( "test" ) works fine.
> 
> So I wonder, what _is_ exactly the print statement? The untraditional
> way of invoking it(without paranteses) makes me wonder.
> 
> The reason I thinks about this is I need to implement a debug print for
> my program; very simple, a function/print statement that conditionally
> prints its message whether a bool is true. Not overly complex.
> 
> I tried this by overshadowing the print keyword, but that obviously
> didn't work.. Is defining a two-liner function the right way to go, or
> is there better ways to approach it?
> 
> 
> Cheers,
> 
>   Frans

Unfortunately, it isnt possible to add new kinds of statements to python.
you might want to have a look at Ruby, in which paren are entirely
optional. Ruby is similar to python in a lot of ways, but its also quite
different. It provides lots of syntactic sugar and a superior object
model, but its a resource hog compared to python.

You may also be interested in Logix. Logix is a language framework built
on top of python that allows you to dynamically extend python syntax at
run-time. Unfortunately, Logix is still rather new, and its incredibly
slow.

http://logix.livelogix.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to call python code from C#

2005-01-25 Thread Ryan Paul
On Tue, 25 Jan 2005 00:35:04 +0530, paritosh mahana wrote:

> Hi all,
> How can I call python code from my C#  code. One thing is to make an
> .exe file of the python program and then try to call it from my C#
> code. But I don't like that idea. Is there any other way to do this.
> Like making a .dll file from the python code and somehow call it from
> C# program.But I couldn't find anything on this topic on the net.
> Actually my GUI is in C#  and rest part is in python, and i need to
> call python from my C# program. Please correct me if I am wrong
> anywhere.
> thanks
> paritosh.

This may not be relevant, but if what you are looking for is a way to
write a program for .NET with a language that doesnt suck, you might want
to look at Boo (http://boo.codehaus.org/). I'm not sure if it can directly
use winforms, but you can probably make native .net libraries with it that
you can utilize from C#. Boo looks and feels almost exactly like
Python, so the learning curve is minimal, and using it is very pleasant.

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


Re: references/addrresses in imperative languages

2005-06-20 Thread SM Ryan
# easy way to see this, is to ask yourself: how come in mathematics
# there's no such thing as "addresses/pointers/references".

The whole point of Goedelisation was to add to name/value references into
number theory. Thus Goedel was able to add back pointers contrary to the
set hierarchy of the theory of types and reintroduce Russel's paradox.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
The little stoner's got a point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: references/addrresses in imperative languages

2005-06-20 Thread SM Ryan
"Kaz Kylheku" <[EMAIL PROTECTED]> wrote:
# SM Ryan wrote:
# > # easy way to see this, is to ask yourself: how come in mathematics
# > # there's no such thing as "addresses/pointers/references".
# >
# > The whole point of Goedelisation was to add to name/value references into
# > number theory.
# 
# Is that so? That implies that there is some table where you can
# associate names (or whatever type of locators: call them pointers,
# whatever) with arbitrary values. But in fact that's not the case.

Do you really believe the Goedel number of a statement is the statement
itself? Is everything named Kaz the same as you?

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Sothat would make Bethany part black?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python syntax high-lighting and preservation on web

2005-06-30 Thread Ryan Bowman


--- Gregory Piñero <[EMAIL PROTECTED]> wrote:

> Hey guys,
> 
> Does anyone know where I can pick up a style sheet (css) and/or other
> files/programs I might need to display python code on my website with
> tab preservation(or replace with spaces) and colored syntax?  I want
> something similar to the python code on a page like this:
> 
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303770
> 
> (I think this is a python-list question although maybe it belongs in a
> css group?)  I figure some of you guys would have experience with
> this.
> 
> -

If you use emacs to edit your code another option is the package htmlize.el,
which produces an html file from a file as it is displayed in emacs, syntax
highlighting and indentation preserved.  I've used it a few times.  It produces
CSS in the head of the html code.

http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el.html



Ryan Bowman

I get the feeling that the compiler just skips over all the comments...




__ 
Yahoo! Mail Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail 
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie question

2005-02-28 Thread Ryan White
Hi all

I'm wanting to use python to display some jpeg images, maybe present them at
a percentage of their actual size etc.

How do I display an image in Python? - I've run over Tkinter, but obviously
in all the wrong places.

Any help or sample code would be much appreciated.

Ryan


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


Re: Optional Static Typing

2004-12-27 Thread Ryan Paul
On Thu, 23 Dec 2004 01:49:35 -0800, bearophileHUGS wrote:

> Adding Optional Static Typing to Python looks like a quite complex
> thing, but useful too:
> http://www.artima.com/weblogs/viewpost.jsp?thread=85551

I wrote a blog post this morning in which I briefly argue using DbC and
predicate based argument constraints instead of static typing. Take a look
if you are interested. It also contains a link to a wiki page where I have
been producing a more refined specification complete with good examples:

http://www.cixar.com/segphault/pytype.html

I would appreciate some feedback, I want to know what other python
programmers think about DbC and arg constraints.

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


Re: [sqlite] Happy New Year

2013-12-31 Thread Ryan Finnesey
Happy New Year to you as well. 

Sent from my iPad

> On Dec 31, 2013, at 7:46 PM, "Igor Korot"  wrote:
> 
> Hi, ALL,
> I want to wish everybody who is reading and involved with the list
> Happy and oyful New Year!
> Let's have a great time in it and lets make a lot of good products and
> new releases with the software that everybody involve with.
> 
> Thank you.
> ___
> sqlite-users mailing list
> sqlite-us...@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
-- 
https://mail.python.org/mailman/listinfo/python-list


[ANN] PyExt 0.6 Released!

2014-02-09 Thread Ryan Gonzalez
PyExt is a set of nifty(and sometimes either overly hackish, overly
dangerous, or overly both) extensions to Python. It has things like a
switch statement, runtime module creation, function overloading(does NOT
work with class methods...yet), and more!

Links:
PyPI: https://pypi.python.org/pypi/pyext
GitHub: https://github.com/kirbyfan64/pyext

-- 
Ryan
If anybody ever asks me why I prefer C++ to C, my answer will be simple:
"It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was
nul-terminated."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to completely uninstall python 2.7 on Windows

2016-01-28 Thread Ryan Gonzalez
Wrong mailing list! You probably want 
https://mail.python.org/mailman/listinfo/python-list

Anyway, does uninstalling from the Control Panel not work?

On January 28, 2016 7:59:00 AM CST, "Shi, Jiajun"  
wrote:
>Hi there,
>
>Please help me to uninstall Python 2.7 on Windows. I want to install
>Python 3, and new python packages are all installed for Python 2.7,
>even I tried uninstalling approaches i searched from web to
>uninstalling previous versions.
>
>Thanks,
>Jiajun Shi 
>-- 
>https://mail.python.org/mailman/listinfo/python-announce-list
>
>Support the Python Software Foundation:
>http://www.python.org/psf/donations/

-- 
Sent from my Nexus 5 with K-9 Mail. Please excuse my brevity.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Calculator

2016-02-01 Thread Ryan Young
I am new to Python but have known Java for a few years now. With python, so
far, so good! I created a simple calculator to calculate the total cost of
a meal. My variables were tip tax total and order. I am confused about how
to put in a new 'order' because when i reset the order variable to a
different number it still calculates the original value. I have sent you a
picture to help you understand my problem. Thank you so much!

Ryan Young
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I love assert

2014-11-13 Thread Lie Ryan

On 13/11/14 10:05, Ian Kelly wrote:

On Wed, Nov 12, 2014 at 3:47 PM, Marko Rauhamaa  wrote:

Ian Kelly :

Apart from idiomatic style, there is no difference between

 # never reached

 assert False

 raise RuntimeError('Unreachable code reached')


If the purpose is communication, then the comment is most effective,
as it can easily convey anything you want. If the purpose is to detect
programming errors, then the RuntimeError is most effective, as it
will always raise an error in the event it is reached.

assert False is a strange hybrid of the two that is less effective at
both purposes.



You can do;

assert False, "Some comments about why this assert is here"



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


Re: Communicating with a PHP script (and pretending I'm a browser)

2014-11-13 Thread Lie Ryan

On 13/11/14 03:57, Larry Martell wrote:

We were all making this much harder than it is. I ended up doing this:

wp = urllib.request.urlopen('http://php_page/?' + request.POST.urlencode())
pw = wp.read()


I was about that suggest that actually, just be careful to escape things 
properly. Although I would recommend to pass the parameters as request 
body rather than as query parameters. Going through the web server via 
HTTP is most definitely going to be even more expensive than with pipes, 
but if performance is the least of your concern, then this is probably 
the easiest way to include things between languages.


Yet another methods of mixing languages is to use iframes and to built 
your frontend as HTML with that queries Web APIs with AJAX but this 
relies on the client side to do the inclusion.


As your goal is to eventually port an existing site to Python, I would 
highly recommend against using Django. Django, as a full-featured 
framework, is quite opinionated on how to do things, especially in 
regards to database design. While this is great for a new projects as it 
enforces certain well-tested patterns, this can be a pain when you need 
to use existing tables from the PHP application. Also, if your old 
application database access is written in SQL (i.e. with PHP mysql or 
mysqli driver), it might be less friction to port to SQLAlchemy Core 
rather than jumping straight to a full-fledged ORM, eventually you can 
slowly take the next step to port SQLA Core to SQLA ORM. Or you can mix 
and match Core and ORM with SQLAlchemy (with some care); Django is much 
less flexible about mixing plain SQL with ORM.


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


Re: [Python-Dev] Dinamically set __call__ method

2014-11-13 Thread Lie Ryan

On 05/11/14 06:15, Roberto Martínez wrote:


The thing with this is tricky. I need the change in the instance,

> not in the class, because I have multiple instances and all of
> them must have different implementations of __call__.

Why not just use functions with closure if that's what you need?

def a(one):
two = 'three'
def mycall(self):
nonlocal two
print 'NEW'
return mycall

Python functions are objects.


The workaround of calling a different method inside __call__

> is not valid for my case because I want to change the *signature*
> of the function also -for introspection reasons.

This seems like they should be two totally separate classes. If the 
signature is different, then it violates the substitution principle. If 
it violates substitution, then there is no reason why they should be of 
the same class.



This was my first approach, but it is not very informative to the user
and I prefer to have arguments with descriptive names. We have to change
__doc__ too, so this is not an ideal solution for me.

I tried to implement __getattribute__, but is not called either. :(



Or you can use an factory function:

def A(p):
def xcall(self):
return 'X'
def ycall(self):
return 'Y'

class _A(object):
__call__ = xcall if p == 'x' else ycall
return _A

>>> A('x')()(), A('y')()()
('X', 'Y')

or plain and simply just use inheritance if you want to pass an 
isinstance check:


class A(object):
def __call__(self):
print 'OLD'

class A1(A):
def __call__(self):
print 'NEW'

What exactly, are you trying to do?

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


Re: Profiler for long-running application

2015-02-09 Thread Ryan Stuart
Hi Asad,

Is there any reason why you can't just use profile/cProfile? In particular,
you could use the api of that module to save out the profile stats to an
external file with a unique name and then inspect them later with a tool
like snakeviz . The code to save
profile stats might look like the following:

pr = cProfile.Profile()
pr.runcall(your_celery_task_without_async)
ps = pstats.Stats(pr)
ps.dump_stats("my_task.profile")

Obviously you need to call your celery task function directly, not via
Celery using delay() or any derivative. Alternatively, you could try
something like line_profiler  by
again, calling the task directly.

If using this method it turn out your actual task code is running quite
fast, then I'd suggest that the majority of the time is being lost in
transferring the task to the Celery node.

Cheers

On Mon Feb 09 2015 at 5:20:43 AM Asad Dhamani  wrote:

> I have a Flask application where I run a specific task asynchronously
> using Celery. Its basically parsing some HTML and inserting data into a
> Postgres database(using SQLAlchemy). However, the task seems to be running
> very slowly, at 1 insert per second.
> I'd like to find out where the bottleneck is, and I've been looking for a
> good profiler that'd let me do this, however, I couldn't find anything. Any
> recommendations would be great.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TypeError: list indices must be integers, not tuple

2015-02-10 Thread Ryan Stuart
Hi,

There is a lot of issues with this code. First, setting fav to a 1 tuples
with a string probably isn't what you want. What you probably mean is:

if restraunt == ("Pizza"):
fav = 1

Second, when you are trying to lookup items in Menu, you are using the
incorrect fav. Lists have int indicies (just like the error points out).
Values like ("1") aren't integers.

Thirdly, Menu is a list of lists. To fetch "Barbeque pizza" from Menu, you
need to do Menu[0][0], not Menu[0, 0].

Finally, Python comes with a style guide which you can find in pep8
. Your code violates that guide
in many places. It might be worth working through the Python Tutorial
.

Cheers

On Tue Feb 10 2015 at 9:55:40 AM  wrote:

> import random
> RandomNum = random.randint(0,7)
> restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or
> Indian?")
> if restraunt == ("Pizza"):
> fav = ("1")
>
> elif restraunt == ("Chinease"):
> fav = ("2")
>
> elif restraunt == ("Indian"):
> fav = ("3")
>
> else:
> print("Try using a capital letter, eg; 'Chinease'")
>
> Menu = [["Barbeque pizza","Peparoni","Hawain"],["
> Curry","Noodles","Rice"],["Tika Masala","Special Rice","Onion Bargees"]]
>
> print Menu[fav,RandomNum]
>^
> TypeError: list indices must be integers, not tuple
>
> How do I set a variable to a random number then use it as a list indece,
> (I'm only a student in his first 6 months of using python)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >