Re: Fastest web framework

2012-09-24 Thread Alec Taylor
Can you throw in web2py?

Thanks

On Sun, Sep 23, 2012 at 7:19 PM, Andriy Kornatskyy <
andriy.kornats...@live.com> wrote:

>
> I have run recently a benchmark of a trivial 'hello world' application for
> various python web frameworks (bottle, django, flask, pyramid, web.py,
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might
> find it interesting:
>
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
>
> Comments or suggestions are welcome.
>
> Thanks.
>
> Andriy Kornatskyy
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Fastest web framework

2012-09-24 Thread Andriy Kornatskyy

Accepted.


> Date: Mon, 24 Sep 2012 17:36:25 +1000 
> Subject: Re: Fastest web framework 
> From: alec.tayl...@gmail.com 
> To: andriy.kornats...@live.com 
> CC: python-list@python.org 
> 
> Can you throw in web2py? 
> 
> Thanks 
> 
> On Sun, Sep 23, 2012 at 7:19 PM, Andriy Kornatskyy 
> mailto:andriy.kornats...@live.com>> wrote: 
> 
> I have run recently a benchmark of a trivial 'hello world' application 
> for various python web frameworks (bottle, django, flask, pyramid, 
> web.py, wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... 
> you might find it interesting: 
> 
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html 
> 
> Comments or suggestions are welcome. 
> 
> Thanks. 
> 
> Andriy Kornatskyy 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list 
> 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Invalid identifier claimed to be valid by docs (methinks)

2012-09-24 Thread Joshua Landau
On 24 September 2012 03:42, Terry Reedy  wrote:

> On 9/23/2012 6:57 PM, Ian Kelly wrote:
>
>> On Sun, Sep 23, 2012 at 4:24 PM, Joshua Landau
>>  wrote:
>>
>>> The docs describe identifiers to have this grammar:
>>>
>>> identifier   ::=  xid_start xid_continue*
>>> id_start ::=  >> Lo,
>>> Nl, the underscore, and characters with the Other_ID_Start property>
>>> id_continue  ::=  >> categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
>>> xid_start::=  >> is in
>>> "id_start xid_continue*">
>>>
>>
> xid_start is a subset of id_start
>
>
>  xid_continue ::=  >> normalization is
>>> in "id_continue*">
>>>
>>
> xid_continue is a subset of id_continue.
>
>
>  So I would assume that
>>>  exec("a{} = None".format(char))
>>> would be valid if
>>> unicodedata.normalize("NFKC", char)  == "1"
>>>
>>
> Read more carefully the definition of xid_continue. The un-normalized
> character must also be in id_continue.
>
Correct. Thank you for your time.


>  as
>>> exec("a1 = None")
>>> is valid.
>>>
>>> BUT "a¹ = None" is not valid*.
>>>
>>
> >>> ud.category("\u00b9")
> 'No'
>
> Category No is *not* in id_continue, and therefore not in xid_continue.
>
>
> exec("x\u00b9 = None")  # U+00B9 is superscript 1
>>
>> On the other hand, this does work:
>>
>> exec("x\u2071 = None")  # U+2071 is superscript i
>>
>> So it seems to be only an issue with superscript and subscript digits.
>>   Looks like a compiler bug to me.
>>
>
> The problem, if there were one, would be in the tokenizer that finds
> identifiers. However,
>
>
> >>> exec("x\u00b9 = None")
> ...
> x¹ = None
>   ^
> SyntaxError: invalid character in identifier
>
> this is correct.


Thank you both for helping. The bug is officially closed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fastest web framework

2012-09-24 Thread Tarek Ziadé

On 9/23/12 11:19 AM, Andriy Kornatskyy wrote:

I have run recently a benchmark of a trivial 'hello world' application for 
various python web frameworks (bottle, django, flask, pyramid, web.py, 
wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find 
it interesting:

http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html

Comments or suggestions are welcome.

Thanks.

Andriy Kornatskyy


I would try this with a web app that does more than 'Hello World'

You may argue that you're just trying the server stack, but that's not 
realistic because you don't really measure how the server behaves with a 
real app.


Have a look at 
https://github.com/mozilla-services/chaussette/blob/master/chaussette/util.py#L188


(setup_bench and teardow_bench have to be run on startup and tear down 
of the server)


I would be curious to see how things goes then

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


style-url support for simplekml

2012-09-24 Thread lodeameije
Hi!
I love the simplekml package. 
I have a lot of files and always use an external file for styles.
For the moment, I could not find how to implement a style-url without running 
over the kml file after generating and changing 'manually'(well, it "is" 
automated) all styles:

i.e.: 
..\..\Cada_Styles.kml#B_CaPa
instead of 
#stylesel_459 (when a style was defined...)

An idea for the next version or am I looking over something?

Kind regards,
Lode
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] [RELEASED] Python 3.3.0 release candidate 3

2012-09-24 Thread Ethan Furman

Mark Lawrence wrote:

On 24/09/2012 07:18, Georg Brandl wrote:


[snip impressive list of improvements]

Yes, but apart from all that, what have the python devs ever done for 
us?  Nothing :)


I'll take that kind of nothing any day of the week!  ;)

~Ethan~

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


Re: Pass numeric arrays from C extensions to Python

2012-09-24 Thread Grant Edwards
On 2012-09-24, JBT  wrote:

> I am looking for a way to pass numeric arrays, such as *float a[100];
> double b[200];*, from C extension codes to python. The use case of
> this problem is that you have data stored in a particular format,
> NASA common data format (CDF) in my case, and there exists an
> official C library to read/create/edit such data, and you want to do
> data analysis in python. The problem comes down to how to feed the
> data into python.

In a addition to scipy and scientific python (two different projects),
you should probably take a look at the struct module and the ctypes
module.

-- 
Grant Edwards   grant.b.edwardsYow! Life is a POPULARITY
  at   CONTEST!  I'm REFRESHINGLY
  gmail.comCANDID!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Jean-Michel Pichavant
- Original Message -
> ytHello all:
> I've asked for a couple code reviews lately on a mud I've been
> working
> on, to kind of help me with ideas and a better design.
> 
> I have yet another design question.
> In my mud, zones are basically objects that manage a collection of
> rooms; For example, a town would be it's own zone.
> It holds information like maxRooms, the list of rooms as well as some
> other data like player owners and access flags.
> The access flags basically is a list holding the uid of a player, as
> well as a bitarray of permissions on that zone. For example, a player
> might have the ability to edit a zone, but not create rooms.
> So I have a couple of questions based on this:
> First, how viable would it be to keep a sort of player database
> around
> with stats and that?
> It could contain the player's level, as well as other information
> like
> their access (player, admin, builder etc), and then when someone does
> a
> whois on the player I don't have to load that player up just to get
> data
> about them. How would I keep the information updated? When I delete a
> player, I could just delete the entry from the database by uid.
> Second, would it be viable to have both the name and the uid stored
> in
> the dictionary? Then I could look up by either of those?
> 
> Also, I have a couple more general-purpose questions relating to the
> mud.
> When I load a zone, a list of rooms get stored on the zone, as well
> as
> world. I thought it might make sense to store references to objects
> located somewhere else but also on the world in WeakValueDictionaries
> to
> save memory. It prevents them from being kept around (and thus having
> to
> be deleted from the world when they lose their life), but also (I
> hope)
> will save memory. Is a weakref going to be less expensive than a full
> reference?
> Second, I want to set up scripting so that you can script events for
> rooms and npcs. For example, I plan to make some type of event
> system,
> so that each type of object gets their own events. For example, when
> a
> player walks into a room, they could trigger some sort of trap that
> would poison them. This leads to a question though: I can store
> scripting on objects or in separate files, but how is that generally
> associated and executed?
> Finally, I just want to make sure I'm doing things right. When I
> store
> data, I just pickle it all, then load it back up again. My world
> object
> has an attribute defined on it called picklevars, which is basically
> a
> list of variables to pickle, and my __getstate__ just returns a
> dictionary of those. All other objects are left "as-is" for now.
> Zones,
> (the entire zone and all it's rooms) get pickled, as well as players
> and
> then the world object for persistence. Is this the suggested way of
> doing things? I'll also pickle the HelpManager object, which will
> basically contain a list of helpfiles that can be accessed, along
> with
> their contents.
> Thanks, and appologies for all the questions.
> 
> --
> Take care,
> Ty
> http://tds-solutions.net
> The aspen project: a barebones light-weight mud engine:
> http://code.google.com/p/aspenmud
> He that will not reason is a bigot; he that cannot reason is a fool;
> he that dares not reason is a slave.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

That's a lot of questions, few specific to python.
I have one advice:

Don't think too much about performances. Focus on keeping things simple, work 
on your design and forget about implementation.
Pickle everything, use sqllite for your database. When you get things working, 
then you can start measuring your performances and think about clever 
implementation to speed up things **if needed** (<- key notion). 


JM

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


Re: Python presentations

2012-09-24 Thread andrea crotti
For anyone interested, I already moved the slides on github
(https://github.com/AndreaCrotti/pyconuk2012_slides)
and for example the decorator slides will be generated from this:

https://raw.github.com/AndreaCrotti/pyconuk2012_slides/master/deco_context/deco.rst

Notice the literalinclude with :pyobject: which allows to include any
function or class automatically very nicely from external files ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Jean-Michel Pichavant
- Original Message -
> >Pickle everything, use sqllite for your database. When you get
> >things
> working, then you can start measuring your performances and think
> >about
> clever implementation
> That was a bunch of information; sorry about that. what do you mean
> by
> using sqlite for the database? Currently I just drop everything into
> files. Is there a better way to do that?
> Thanks for your advice.

Please keep the discussion on list.

If you have a basic knowledge of databases, sure you could use a sqlite 
database to store you persistent objects. That's pretty reasonable.
Not to mention a lot of stuff can interface with that database. If you want to 
build a web app to manage the player database, you can, most of the frameworks 
handles sqlite. Actually if you don't need a web app, a lot of sqlite admin app 
already exists.

Note that the database is suitable only for the data. For serializing a python 
object with its code, you need pickle.

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


Re: Exact integer-valued floats

2012-09-24 Thread wrw
On Sep 22, 2012, at 7:06 PM, Dave Angel  wrote:

> On 09/22/2012 05:05 PM, Tim Roberts wrote:
>> Dennis Lee Bieber  wrote:
>>> On 22 Sep 2012 01:36:59 GMT, Steven D'Aprano wrote:
 For non IEEE 754 floating point systems, there is no telling how bad the 
 implementation could be :(
>>> Let's see what can be found...
>>> 
>>> IBM 360: Same as Sigma-6 (no surprise; hearsay is the Sigma was
>>> designed by renegade IBM folk; even down to using EBCDIC internally --
>>> but with a much different interrupt system [224 individual interrupt
>>> vectors as I recall, vs the IBM's 7 vectors and polling to find what
>>> device]).
>> The Control Data 6000/Cyber series had sign bit and 11-bit exponent, with
>> either a 48-bit mantissa or a 96-bit mantissa, packed into one or two
>> 60-bit words.  Values were not automatically normalized, so there was no
>> assumed 1 bit, as in IEEE-754.
> 
> And it's been a long time (about 39 years), but as I recall the CDC 6400
> (at least) had no integer multiply or divide.  You had to convert to
> float first.  The other oddity about the CDC series is it's the last
> machine I've encountered that used ones-complement for ints, with two
> values for zero.
> 
> 

Well, for what it is worth… the DEC Laboratory INstrument Computer (LINC-8, 
sort of a forced acronym because I believe they were built to specs issued by 
Lincoln Labs.) and the later DEC PDP-12 (which incorporated the LINC-8 
instruction set, along with the PDP-8 basic set) also did ones-complement 
integer arithmetic.  I never used a LINC-8, but I worked for several years 
around PDP-12s.  (They also had a build-in CRT and a MUX'd analog-to-digital 
converter with CPU instructions for driving both directly.)  As I remember, 
they maxed out at 32k (12-bit) words of RAM.  I don't know when they were 
discontinued, but there were still some PDP-12s in use as late as 1988 when I 
lost track. 

-Bil


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

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


Re: Java singletonMap in Python

2012-09-24 Thread Duncan Booth
Steven D'Aprano  wrote:

> On Mon, 24 Sep 2012 00:14:23 +0100, Mark Lawrence wrote:
> 
>> Purely for fun I've been porting some code to Python and came across
>> the singletonMap[1].  I'm aware that there are loads of recipes on
>> the web for both singletons e.g.[2] and immutable dictionaries
>> e.g.[3].  I was wondering how to combine any of the recipes to
>> produce the best implementation, where to me best means cleanest and
>> hence most maintainable.  I then managed to muddy the waters for
>> myself by recalling the Alex Martelli Borg pattern[4].  Possibly or
>> even probably the latter is irrelevant, but I'm still curious to know
>> how you'd code this beast.
>> 
>> First prize for the best solution is a night out with me, no guesses
>> what the second prize is :)
>> 
>> [1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/
> Collections.html
> 
> Copied from that page:
> 
> "static Map singletonMap(Object key, Object value) 
> Returns an immutable map, mapping only the specified key to the
> specified value."
> 
> I don't see the point of this. It takes a single key, with a single 
> value, and is immutable so you can't change it or add new keys. What's
> the point? Why bother storing the key:value pair in a data structure, 
> then look up the same data structure to get the same value every time?
> 
> # Pseudo-code
> d = singletonMap(key, calculate(key))
> # later:
> value = d[key]  # there's only one key this could be
> process(value)
> 
> 
> Why not just store the value, instead of key, value and mapping?
> 
> value = calculate(key)
> # later
> process(value)
> 
> 
> 
Google is your friend. Searching for "java singletonMap" gives this as
the second hit:

http://stackoverflow.com/questions/7125536/when-would-i-use-java-collections-singletonmap-method

The answers seem to be that it's for all those cases in Java where you have a 
method that takes a map as an argument and you want to pass in a map with a 
single
kep/value pair. In that case it lets you replace 3 lines of Java with 1.

e.g. from the comments:
"If you have a simple select statement like "select foo from bar where id = 
:barId" 
then you would need a parameter map with a single key-value pair, barId=123. 
That's a great place to use singletonMap()"

Of course in Python you just use a dict literal in that case so it's pointless.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: write to a file two dict()

2012-09-24 Thread inq1ltd
On Sunday, September 23, 2012 10:44:30 AM giuseppe.amatu...@gmail.com wrote:
> Hi
> Have two dict() of the same length and i want print them to a common file.
> 
> 
> a={1: 1, 2: 2, 3: 3}
> b={1: 11, 2: 22, 3: 33}
> 
> in order to obtain
> 
> 1 1 1 11
> 2 2 2 22
> 3 3 3 33
> 
> I tried
> 
> output = open(dst_file, "w")
> for (a), b , (c) , d in a.items() , b.items() :
> output.write("%i %i %i %i\n" % (a,b,c,d))
> output.close()

Try this, not exactly what you want, but close.

Refine it to get what you want.

dictC = {}

a={1: 1, 2: 2, 3: 3}
b={1: 11, 2: 22, 3: 33}

for bkey in b.keys():

newlist = []
x = str(b.get(bkey, ''))
x = str(bkey)+x
newlist.append(x)

y = str(a.get(bkey, ''))
y = str(bkey)+y
newlist.append(y)

dictC[bkey] = newlist

print dictC, 


jimonlinux,
inqvista.com


> 
> but i get the error ValueError: need more than 3 values to unpack.
> 
> do you have some suggestions?.
> Thanks
> Giuseppe-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does python have built command for package skeleton creation?

2012-09-24 Thread 88888 Dihedral
xliiv於 2012年9月21日星期五UTC+8下午9時13分38秒寫道:
> On Friday, September 21, 2012 3:04:02 PM UTC+2, Tarek Ziadé wrote:
> 
> > On 9/21/12 2:14 PM, xliiv wrote:
> 
> > 
> 
> > >
> 
> > 
> 
> > > Python Paste is probably what you are looking for - see
> 
> > 
> 
> > >
> 
> > 
> 
> > > http://lucasmanual.com/mywiki/PythonPaste for example
> 
> > 
> 
> > > It's a nice beast but:
> 
> > 
> 
> > > - it's not built in. Should it be? I think it should.
> 
> > 
> 
> > You can suggest this to python-ideas but I really doubt you will get any 
> 
> > 
> 
> > traction. The sdtlib don't get new features these days because it's a burden
> 
> > 
> 
> > to maintain high level tool on a 2 years release cycle
> 
> 
> 
> Why is this '2 years release cycle'?

This is good in python to focus on comming HW patforms with 
varied parameters as the industry is advacing toward  all way 
to avoid a heavy landing of the IT and electronics industry.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Java singletonMap in Python

2012-09-24 Thread 88888 Dihedral
Duncan Booth於 2012年9月25日星期二UTC+8上午1時33分31秒寫道:
> Steven D'Aprano  wrote:
> 
> 
> 
> > On Mon, 24 Sep 2012 00:14:23 +0100, Mark Lawrence wrote:
> 
> > 
> 
> >> Purely for fun I've been porting some code to Python and came across
> 
> >> the singletonMap[1].  I'm aware that there are loads of recipes on
> 
> >> the web for both singletons e.g.[2] and immutable dictionaries
> 
> >> e.g.[3].  I was wondering how to combine any of the recipes to
> 
> >> produce the best implementation, where to me best means cleanest and
> 
> >> hence most maintainable.  I then managed to muddy the waters for
> 
> >> myself by recalling the Alex Martelli Borg pattern[4].  Possibly or
> 
> >> even probably the latter is irrelevant, but I'm still curious to know
> 
> >> how you'd code this beast.
> 
> >> 
> 
> >> First prize for the best solution is a night out with me, no guesses
> 
> >> what the second prize is :)
> 
> >> 
> 
> >> [1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/
> 
> > Collections.html
> 
> > 
> 
> > Copied from that page:
> 
> > 
> 
> > "static Map singletonMap(Object key, Object value) 
> 
> > Returns an immutable map, mapping only the specified key to the
> 
> > specified value."
> 
> > 
> 
> > I don't see the point of this. It takes a single key, with a single 
> 
> > value, and is immutable so you can't change it or add new keys. What's
> 
> > the point? Why bother storing the key:value pair in a data structure, 
> 
> > then look up the same data structure to get the same value every time?
> 
> > 
> 
> > # Pseudo-code
> 
> > d = singletonMap(key, calculate(key))
> 
> > # later:
> 
> > value = d[key]  # there's only one key this could be
> 
> > process(value)
> 
> > 
> 
> > 
> 
> > Why not just store the value, instead of key, value and mapping?
> 
> > 
> 
> > value = calculate(key)
> 
> > # later
> 
> > process(value)
> 
> > 
> 
> > 
> 
> > 
> 
> Google is your friend. Searching for "java singletonMap" gives this as
> 
> the second hit:
> 
> 
> 
> http://stackoverflow.com/questions/7125536/when-would-i-use-java-collections-singletonmap-method
> 
> 
> 
> The answers seem to be that it's for all those cases in Java where you have a 
> 
> method that takes a map as an argument and you want to pass in a map with a 
> single
> 
> kep/value pair. In that case it lets you replace 3 lines of Java with 1.
> 
> 
> 
> e.g. from the comments:
> 
> "If you have a simple select statement like "select foo from bar where id = 
> :barId" 
> 
> then you would need a parameter map with a single key-value pair, barId=123. 
> 
> That's a great place to use singletonMap()"
> 
> 
> 
> Of course in Python you just use a dict literal in that case so it's 
> pointless.
> 
> 
> 
> -- 
> 
> Duncan Booth http://kupuguy.blogspot.com

Cheers to those who are programmers that really love  authoring in the high 
level one with tools to translate into other computer languages,
and also collecting  the upgrade fees from clients.


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


Re: Java singletonMap in Python

2012-09-24 Thread Devin Jeanpierre
On Sun, Sep 23, 2012 at 7:14 PM, Mark Lawrence  wrote:
> Purely for fun I've been porting some code to Python and came across the
> singletonMap[1].  I'm aware that there are loads of recipes on the web for
> both singletons e.g.[2] and immutable dictionaries e.g.[3].  I was wondering
> how to combine any of the recipes to produce the best implementation

The word "singleton" usually means "thing with only one item". For
example, {a} is a singleton set containing only a, and with matrices,
any dimension of size one is called a singleton dimension, and so on.
In this case, a singleton map is a map with only one key-value pair,
such as {a:b}.

The singleton design antipattern is not relevant here.

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


Re: Java singletonMap in Python

2012-09-24 Thread Mark Lawrence

On 24/09/2012 18:33, Duncan Booth wrote:

Steven D'Aprano  wrote:


On Mon, 24 Sep 2012 00:14:23 +0100, Mark Lawrence wrote:


Purely for fun I've been porting some code to Python and came across
the singletonMap[1].  I'm aware that there are loads of recipes on
the web for both singletons e.g.[2] and immutable dictionaries
e.g.[3].  I was wondering how to combine any of the recipes to
produce the best implementation, where to me best means cleanest and
hence most maintainable.  I then managed to muddy the waters for
myself by recalling the Alex Martelli Borg pattern[4].  Possibly or
even probably the latter is irrelevant, but I'm still curious to know
how you'd code this beast.

First prize for the best solution is a night out with me, no guesses
what the second prize is :)

[1]http://docs.oracle.com/javase/1.4.2/docs/api/java/util/

Collections.html

Copied from that page:

"static Map singletonMap(Object key, Object value)
Returns an immutable map, mapping only the specified key to the
specified value."

I don't see the point of this. It takes a single key, with a single
value, and is immutable so you can't change it or add new keys. What's
the point? Why bother storing the key:value pair in a data structure,
then look up the same data structure to get the same value every time?

# Pseudo-code
d = singletonMap(key, calculate(key))
# later:
value = d[key]  # there's only one key this could be
process(value)


Why not just store the value, instead of key, value and mapping?

value = calculate(key)
# later
process(value)




Google is your friend. Searching for "java singletonMap" gives this as
the second hit:

http://stackoverflow.com/questions/7125536/when-would-i-use-java-collections-singletonmap-method

The answers seem to be that it's for all those cases in Java where you have a
method that takes a map as an argument and you want to pass in a map with a 
single
kep/value pair. In that case it lets you replace 3 lines of Java with 1.

e.g. from the comments:
"If you have a simple select statement like "select foo from bar where id = 
:barId"
then you would need a parameter map with a single key-value pair, barId=123.
That's a great place to use singletonMap()"

Of course in Python you just use a dict literal in that case so it's pointless.



Thank goodness for that, I'd assumed that I'd missed something blatantly 
obvious.  There are two chances of something like this getting into the 
standard library, zero or none.  I think in a way that's a great pity as 
I'm sure that the Python devs would enjoy supporting the little feller 
with code such as this http://tinyurl.com/9v7d7ld :)


--
Cheers.

Mark Lawrence.

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


Re: Fastest web framework

2012-09-24 Thread Albert Hopkins
On Sun, 2012-09-23 at 12:19 +0300, Andriy Kornatskyy wrote:
> I have run recently a benchmark of a trivial 'hello world' application for 
> various python web frameworks (bottle, django, flask, pyramid, web.py, 
> wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might find 
> it interesting:
> 
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> 
> Comments or suggestions are welcome.
> 

The thing I don't like about these benchmarks is.. they tell you which
framework is best for writing a trivial 'hello world' application.  But
no one writes trivial 'hello world' applications.  A
framework/programming language/software package/what-have-you.  Can be
really fast for trivial stuff, but perform much less favorably when
performing "real-world" tasks.  It's kind of the same argument that's
used when people say X computer boots faster than Y computer.  That's
nice and all, but I spend much more of my time *using* my computer than
*booting* it, so it doesn't give me a good picture of how the computers
perform.  This is why most "good" benchmarks run a series various tests
based on real-world use cases.

-a


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


Re: Java singletonMap in Python

2012-09-24 Thread Mark Lawrence

On 24/09/2012 20:22, Devin Jeanpierre wrote:

On Sun, Sep 23, 2012 at 7:14 PM, Mark Lawrence  wrote:

Purely for fun I've been porting some code to Python and came across the
singletonMap[1].  I'm aware that there are loads of recipes on the web for
both singletons e.g.[2] and immutable dictionaries e.g.[3].  I was wondering
how to combine any of the recipes to produce the best implementation


The word "singleton" usually means "thing with only one item". For
example, {a} is a singleton set containing only a, and with matrices,
any dimension of size one is called a singleton dimension, and so on.
In this case, a singleton map is a map with only one key-value pair,
such as {a:b}.

The singleton design antipattern is not relevant here.

-- Devin



Java thinks so otherwise there wouldn't also be the singleton which is 
the spelling for singletonSet (don't ask me!!!) and a singletonList. 
From the Python viewpoint I think YAGNI is perfect.  I now understand 
why the BDFL and others fight so hard to keep bloatware out of the 
standard library.


--
Cheers.

Mark Lawrence.

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


Re: Does python have built command for package skeleton creation?

2012-09-24 Thread Daniel Nogues

alternatively you can use virtualenv to create virtual environments

http://www.virtualenv.org/en/latest/index.html

however, if what you want is automated generation of some of the code,  
you can adopt an IDE or create some macros in your text editor of  
choice.



From: alex23 
Date: 24 September 2012 06:00:01 IST
To: python-list@python.org
Subject: Re: Does python have built command for package skeleton  
creation?



On Sep 24, 2:29 pm, Terry Reedy  wrote:
Batteries are batteries, not flashlights, phone, radios, toys,  
clickers,

etc.


I decided not to mention "venv" as it undermines my rant a little :)



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


PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread Gelonida N

Hi,

I'm trying to migrate a project with legacy code from 2.6 (with PIL 
1.1.6) to 2.7 with (PIL 1.1.7)

The SW should run on Windows.


PIL fails with an error concering '_imagingft'
This seems to be a known issue.

http://code.google.com/p/pythonxy/issues/detail?id=300
and the bug was never closed.

One suggestion is to download an alternative build from a non official site.

Looking at the activity of PIL ( 
http://www.pythonware.com/products/pil/index.htm ) it seems, that 
development stopped,
The latest build (with known bugs and missing functionality for python 
2.7.) seems to be from November 15, 2009.
In the net I read, that there's so little activity on PIL, because it's 
stable, which doesn't seem to be the case for the 2.7 binary package.


This all does not sound very comforting. Why is there no fix on the 
official site?


I wondered whether some of you have a little more insight into what's 
going on with PIL.


Short term: get PIL working on 2.7 windows?

My shortterm problem is migrating existing code to 2.7 and keeping the 
code, that uses PIL.
So I'll probably try to install the custom binary, but would like to 
know whether anybody has experience with this build.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

Alternatively how tricky is PIL to be compiled with mingw?



Mid term: What to use to manipulate images?


My midterm problem is to stay with Python 2.7 and to write occasinally 
new code, that does some basic image manipulations.


Can I still count on PIL? The fact, that the official devs don't even 
bother to fix some basic functionality of their binary release tells me 
that either very few people use PIL (or at least the broken 
functionality somehow related to the font libraries) on 2.7


What alternatives do exist for PIL?
We just need some lines drawn, some text drown, some scaling, 
transparency merging, . . . and PIL seend decent enough.


There seems to be freeimagepy, but the bindings seem to be 'only' ctypes 
bindings http://freeimagepy.sourceforge.net/

Any experience with this libraries?

Any other suggestions?



Longterm Will PIL officially exist for Python 3?
-

When really all libraries that the project  needs are supported
I''ll probably migrate to Python 3.

For Python 3 there is not even a broken official release, but only forks.

Why isn't any of these forks becoming 'official'?

If a package is not supported for Windows via official binary releases / 
easy_install, then I'm a little more afraid, that the package 
(maintainers included) will disappear in the near future.


Thanks a lot in advance for opinions / recommendations / clarifications









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


RE: Fastest web framework

2012-09-24 Thread Andriy Kornatskyy

Try to see 'Hello World' benchmark as an answer to the question how effective 
is the framework inside...

If computer X boots faster than Y, it means it is more effective in this 
particular area.

If a sportsman runs a distance 1 second faster than other, he got a medal (it 
is not quite adequate to say if I load sportsman with 50 kilo bag he will not 
run that fast... just try split the concerns).

Thanks.

Andriy



> Subject: Re: Fastest web framework
> From: mar...@letterboxes.org
> To: python-list@python.org
> Date: Mon, 24 Sep 2012 15:42:00 -0400
>
> On Sun, 2012-09-23 at 12:19 +0300, Andriy Kornatskyy wrote:
> > I have run recently a benchmark of a trivial 'hello world' application for 
> > various python web frameworks (bottle, django, flask, pyramid, web.py, 
> > wheezy.web) hosted in uWSGI/cpython2.7 and gunicorn/pypy1.9... you might 
> > find it interesting:
> >
> > http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
> >
> > Comments or suggestions are welcome.
> >
>
> The thing I don't like about these benchmarks is.. they tell you which
> framework is best for writing a trivial 'hello world' application. But
> no one writes trivial 'hello world' applications. A
> framework/programming language/software package/what-have-you. Can be
> really fast for trivial stuff, but perform much less favorably when
> performing "real-world" tasks. It's kind of the same argument that's
> used when people say X computer boots faster than Y computer. That's
> nice and all, but I spend much more of my time *using* my computer than
> *booting* it, so it doesn't give me a good picture of how the computers
> perform. This is why most "good" benchmarks run a series various tests
> based on real-world use cases.
>
> -a
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone able to help on installing packages?

2012-09-24 Thread John Mordecai Dildy
Anyone have Ideas on nose and distribute?
-- 
http://mail.python.org/mailman/listinfo/python-list


metaclass question

2012-09-24 Thread Chris Withers

Hi All,

Is there a metaclass-y way I could cause the following:

class TheParser(Parser):
def handle_ARecord(self):
pass
def handle_ARecord(self):
pass

...to raise an exception as a result of the 'handle_ARecord' name being 
reused?


cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: metaclass question

2012-09-24 Thread Ian Kelly
On Mon, Sep 24, 2012 at 11:43 AM, Chris Withers  wrote:
> Hi All,
>
> Is there a metaclass-y way I could cause the following:
>
> class TheParser(Parser):
> def handle_ARecord(self):
> pass
> def handle_ARecord(self):
> pass
>
> ...to raise an exception as a result of the 'handle_ARecord' name being
> reused?

In Python 2.x, no.

In Python 3.x, the __prepare__ method of the metaclass allows you to
specify a custom namespace object for the class definition.  The most
commonly cited use case is to use an OrderedDict to remember the order
in which the attributes are defined, but you could also use a dict
subclass that raises an exception if an attribute is redefined.  See
the docs at:

http://docs.python.org/dev/reference/datamodel.html#preparing-the-class-namespace
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: request for another code review

2012-09-24 Thread Littlefield, Tyler

On 9/23/2012 9:48 PM, alex23 wrote:

On Sep 23, 6:14 am, "Littlefield, Tyler"  wrote:

I've gotten a bit farther into my python mud, and wanted to request
another code review for style and the like.

Are you familiar with codereview.stackexchange.com ?



I actually wasn't, thanks!



(This isn't to dissuade you from posting such requests here, just to
help increase the chance of eyeballs on your code.)



--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

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


Re: request for another code review

2012-09-24 Thread Littlefield, Tyler

On 9/23/2012 9:48 PM, alex23 wrote:

On Sep 23, 6:14 am, "Littlefield, Tyler"  wrote:

I've gotten a bit farther into my python mud, and wanted to request
another code review for style and the like.

Are you familiar with codereview.stackexchange.com ?



I actually wasn't, thanks!



(This isn't to dissuade you from posting such requests here, just to
help increase the chance of eyeballs on your code.)



--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

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


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
> I have yet another design question.
> In my mud, zones are basically objects that manage a collection of rooms;
> For example, a town would be it's own zone.
> It holds information like maxRooms, the list of rooms as well as some other
> data like player owners and access flags.
> The access flags basically is a list holding the uid of a player, as well as
> a bitarray of permissions on that zone. For example, a player might have the
> ability to edit a zone, but not create rooms.
> So I have a couple of questions based on this:
> First, how viable would it be to keep a sort of player database around with
> stats and that?
Well, what are the main items you need to retain for the player to
return to the game?

Also, If this is a browser app I'd go with phpmyadmin, and MySQL

If a tkinter/wxpython/etc app, then maybe sqlite.

> It could contain the player's level, as well as other information like their
> access (player, admin, builder etc), and then when someone does a whois on
> the player I don't have to load that player up just to get data about them.
> How would I keep the information updated? When I delete a player, I could
> just delete the entry from the database by uid.
> Second, would it be viable to have both the name and the uid stored in the
> dictionary? Then I could look up by either of those?
>
Why would you use a dictionary, when it's DB manipulation you're after?

> Also, I have a couple more general-purpose questions relating to the mud.
> When I load a zone, a list of rooms get stored on the zone, as well as
> world. I thought it might make sense to store references to objects located
> somewhere else but also on the world in WeakValueDictionaries to save
> memory. It prevents them from being kept around (and thus having to be
> deleted from the world when they lose their life), but also (I hope) will
> save memory. Is a weakref going to be less expensive than a full reference?

For any case, you're going to have a DB field with a value, so it
doesn't look like a high value memory cost in the DB.

> Second, I want to set up scripting so that you can script events for rooms
> and npcs. For example, I plan to make some type of event system, so that
> each type of object gets their own events. For example, when a player walks
> into a room, they could trigger some sort of trap that would poison them.
> This leads to a question though: I can store scripting on objects or in
> separate files, but how is that generally associated and executed?

Well, the event doesn't need to be stored unless there is a necessity
to store the event, but if it's poisoned, then it's just a life
penalty, then no need to store the event, just the score loss.

> Finally, I just want to make sure I'm doing things right. When I store data,
> I just pickle it all, then load it back up again. My world object has an
> attribute defined on it called picklevars, which is basically a list of
> variables to pickle, and my __getstate__ just returns a dictionary of those.
> All other objects are left "as-is" for now. Zones, (the entire zone and all
> it's rooms) get pickled, as well as players and then the world object for
> persistence. Is this the suggested way of doing things? I'll also pickle the
> HelpManager object, which will basically contain a list of helpfiles that

I might suggest you take a look at the Blender Game Engine(python API)
at this point, unless you're just liking doing it the hard way to gain
experience(just like I have).

Design the DB, and let the scene render what needs to be rendered, or
list data  for, and those are the necessities to be stored.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A little morning puzzle

2012-09-24 Thread Dwight Hutto
> Ergo: 'enumerate()' is the correct suggestion over manually
> maintaining your own index, despite it ostensibly being "more" code
> due to its implementation.

But, therefore, that doesn't mean that the coder can just USE a
function, and not be able to design it themselves. So 'correct
suggestion' is a moot point.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone able to help on installing packages?

2012-09-24 Thread Oscar Benjamin
On 24 September 2012 21:27, John Mordecai Dildy  wrote:

> Anyone have Ideas on nose and distribute?


Your post has no context and simply asks a very vague question. Had you
explained what you tried and what happened and perhaps shown an error
message I might have been able to answer your question in this post.

Presumably you tried something before posting?

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


Re: Anyone able to help on installing packages?

2012-09-24 Thread Dwight Hutto
You could just take the python code, and put it in the site packages
file. Depends on the package.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


python file API

2012-09-24 Thread zipher
For some time now, I've wanted to suggest a better abstraction for the  
type in Python.  It currently uses an antiquated C-style interface for moving 
around in a file, with methods like tell() and seek().  But after attributes 
were introduced to Python, it seems it should be re-addressed.

Let file-type have an attribute .pos for position.   Now you can get rid of the 
seek() and tell() methods and manipulate the file pointer more easily with 
standard arithmetic operations. 

>>> file.pos = x0ae1  #move file pointer to an absolute address 
>>> file.pos +=1#increment the file pointer one byte
>>> curr_pos = file.pos  #read current file pointer

You've now simplified the API by the removal of two obscure legacy methods and 
replaced them with a more basic one called "position".

Thoughts?

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


Re: python file API

2012-09-24 Thread Dave Angel
On 09/24/2012 05:35 PM, zipher wrote:
> For some time now, I've wanted to suggest a better abstraction for the  
> type in Python.  It currently uses an antiquated C-style interface for moving 
> around in a file, with methods like tell() and seek().  But after attributes 
> were introduced to Python, it seems it should be re-addressed.
>
> Let file-type have an attribute .pos for position.   Now you can get rid of 
> the seek() and tell() methods and manipulate the file pointer more easily 
> with standard arithmetic operations. 
>
 file.pos = x0ae1  #move file pointer to an absolute address 
 file.pos +=1#increment the file pointer one byte
 curr_pos = file.pos  #read current file pointer
> You've now simplified the API by the removal of two obscure legacy methods 
> and replaced them with a more basic one called "position".
>
> Thoughts?
>
> markj

And what approach would you use for positioning relative to
end-of-file?  That's currently done with an optional second parameter to
seek() method.




-- 

DaveA

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


Re: A little morning puzzle

2012-09-24 Thread Ethan Furman

Ian Kelly wrote:

On Sat, Sep 22, 2012 at 9:44 PM, Dwight Hutto  wrote:

Why don't you all look at the code(python and C), and tell me how much
code it took to write the functions the other's examples made use of
to complete the task.

Just because you can use a function, and make it look easier, doesn't
mean the function you used had less code than mine, so if you look at
the whole of what you used to make it simpler, mine was on point.


I understood the sarcastic comments (the first one, at least) to be
referring to your solution as bad not due to complexity (I actually
thought it was quite simple), but because it does not solve the
problem as stated.  The problem posed by the OP was to find a set of
common keys that are associated with the same values in each dict.
Your solution takes only one predetermined key-value pair and counts
how many times it occurs in the dicts, which isn't even close to what
was requested.  With your comment of "Might be better ones, though", I
actually thought that you were aware of this and were being
intentionally satirical.


Unlikely.

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


Re: python file API

2012-09-24 Thread Oscar Benjamin
On 24 September 2012 22:35, zipher  wrote:

> For some time now, I've wanted to suggest a better abstraction for the
>  type in Python.  It currently uses an antiquated C-style interface
> for moving around in a file, with methods like tell() and seek().  But
> after attributes were introduced to Python, it seems it should be
> re-addressed.
>
> Let file-type have an attribute .pos for position.   Now you can get rid
> of the seek() and tell() methods and manipulate the file pointer more
> easily with standard arithmetic operations.
>
> >>> file.pos = x0ae1  #move file pointer to an absolute address
> >>> file.pos +=1#increment the file pointer one byte
> >>> curr_pos = file.pos  #read current file pointer
>

seek() and tell() can raise exceptions on some files. Exposing pos as an
attribute and allowing it to be manipulated with attribute access gives the
impression that it is always meaningful to do so.

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


Re: python file API

2012-09-24 Thread Chris Kaynor
On Mon, Sep 24, 2012 at 2:49 PM, Dave Angel  wrote:
>
> And what approach would you use for positioning relative to
> end-of-file?  That's currently done with an optional second parameter to
> seek() method.
>

I'm not advocating for or against the idea, but that could be handled
the same way indexing into lists can index relative to the end:
negative indices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Memory usage per top 10x usage per heapy

2012-09-24 Thread MrsEntity
Hi all,

I'm working on some code that parses a 500kb, 2M line file line by line and 
saves, per line, some derived strings into various data structures. I thus 
expect that memory use should monotonically increase. Currently, the program is 
taking up so much memory - even on 1/2 sized files - that on 2GB machine I'm 
thrashing swap. What's strange is that heapy (http://guppy-pe.sourceforge.net/) 
is showing that the code uses about 10x less memory than reported by top, and 
the heapy data seems consistent with what I was expecting based on the objects 
the code stores. I tried using memory_profiler 
(http://pypi.python.org/pypi/memory_profiler) but it didn't really provide any 
illuminating information. The code does create and discard a number of objects 
per line of the file, but they should not be stored anywhere, and heapy seems 
to confirm that. So, my questions are:

1) For those of you kind enough to help me figure out what's going on, what 
additional data would you like? I didn't want swamp everyone with the code and 
heapy/memory_profiler output but I can do so if it's valuable.
2) How can I diagnose (and hopefully fix) what's causing the massive memory 
usage when it appears, from heapy, that the code is performing reasonably?

Specs: Ubuntu 12.04 in Virtualbox on Win7/64, Python 2.7/64

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


Re: A little morning puzzle

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 5:18 PM, Ethan Furman  wrote:
> Ian Kelly wrote:
>>
>> On Sat, Sep 22, 2012 at 9:44 PM, Dwight Hutto 
>> wrote:
>>>
>>> Why don't you all look at the code(python and C), and tell me how much
>>> code it took to write the functions the other's examples made use of
>>> to complete the task.n in or register.
>>>
>>> Just because you can use a function, and make it look easier, doesn't
>>> mean the function you used had less code than mine, so if you look at
>>> the whole of what you used to make it simpler, mine was on point.
>>
>>
>> I understood the sarcastic comments (the first one, at least) to be
>> referring to your solution as bad not due to complexity (I actually
>> thought it was quite simple), but because it does not solve the
>> problem as stated.  The problem posed by the OP was to find a set of
>> common keys that are associated with the same values in each dict.

>> Your solution takes only one predetermined key-value pair and counts
>> how many times it occurs in the dicts, which isn't even close to what

They stated:

I have a list of dictionaries.  They all have the same keys.  I want to find the
set of keys where all the dictionaries have the same values.  Suggestions?

No, to me it meant to find similar values in several dicts with the
same key, and value. So I created several dicts, and some with the
same key and value, and showed the matches.

The OP can comment as to whether that is the correct interpretation of
the situation.


>> was requested.  With your comment of "Might be better ones, though", I
>> actually thought that you were aware of this and were being
>> intentionally satirical.

I am. I just write out the algorithm as I understand the OP to want
it, to give my version of the example.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Chris Angelico
On Tue, Sep 25, 2012 at 7:49 AM, Dave Angel  wrote:
> On 09/24/2012 05:35 PM, zipher wrote:
>> Let file-type have an attribute .pos for position.   Now you can get rid of 
>> the seek() and tell() methods and manipulate the file pointer more easily 
>> with standard arithmetic operations.
>>
> file.pos = x0ae1  #move file pointer to an absolute address
> file.pos +=1#increment the file pointer one byte
> curr_pos = file.pos  #read current file pointer
>
> And what approach would you use for positioning relative to
> end-of-file?  That's currently done with an optional second parameter to
> seek() method.

Presumably the same way you reference a list element relative to
end-of-list: negative numbers. However, this starts to feel like magic
rather than attribute assignment - it's like manipulating the DOM in
JavaScript, you set an attribute and stuff happens. Sure it's legal,
but is it right? Also, it makes bounds checking awkward:

file.pos = 42 # Okay, you're at position 42
file.pos -= 10 # That should put you at position 32
foo = file.pos # Presumably foo is the integer 32
file.pos -= 100 # What should this do?
foo -= 100 # But this sets foo to the integer -68
file.pos = foo # And this would set the file pointer 68 bytes from end-of-file.

I don't see it making sense for "file.pos -= 100" to suddenly put you
near the end of the file; it should either cap and put you at position
0, or do what file.seek(-100,1) would do and throw an exception. But
doing the exact same operation on a saved snapshot of the position and
reassigning it would then have quite different semantics in an unusual
case, while still appearing identical in the normal case.

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


Re: For Counter Variable

2012-09-24 Thread Ethan Furman

jimbo1qaz wrote:

On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:

Am I missing something obvious, or do I have to manually put in a counter in 
the for loops? That's a very basic request, but I couldn't find anything in the 
documentation.


Ya, they should really give a better way, but for now, enumerate works pretty 
well.


ROFLOL!!

I look forward to the day when you look back on that statement and 
think, "Wow, I've come a long way!"


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


Re: keeping information about players around

2012-09-24 Thread Chris Angelico
On Tue, Sep 25, 2012 at 7:14 AM, Dwight Hutto  wrote:
> Also, If this is a browser app I'd go with phpmyadmin, and MySQL
>
> If a tkinter/wxpython/etc app, then maybe sqlite.

Out of curiosity, why? MySQL isn't magically better for everything
where data ends up displayed in a web browser. Unless you're planning
to also reference this database from some other language, it's going
to make little difference what backend you use; and even if you are
using multiple languages, it's usually not difficult to find overlap.

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


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 6:09 PM, Ethan Furman  wrote:
> jimbo1qaz wrote:
>>
>> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
>>>
>>> Am I missing something obvious, or do I have to manually put in a counter
>>> in the for loops? That's a very basic request, but I couldn't find anything
>>> in the documentation.
>>
>>
>> Ya, they should really give a better way, but for now, enumerate works
>> pretty well.
>
>
> ROFLOL!!
>
> I look forward to the day when you look back on that statement and think,
> "Wow, I've come a long way!"
>

It's a function usage. Not to be too serious, there are usually
simpler solutions, and built in functions.

But you usually sticks with what works, and seems timely in return of
data output

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 6:19 PM, Chris Angelico  wrote:
> On Tue, Sep 25, 2012 at 7:14 AM, Dwight Hutto  wrote:
>> Also, If this is a browser app I'd go with phpmyadmin, and MySQL
>>
>> If a tkinter/wxpython/etc app, then maybe sqlite.
>
> Out of curiosity, why? MySQL isn't magically better for everything
> where data ends up displayed in a web browser.

No, but phpmyadmin is a great GUI for MySQL

Unless you're planning
> to also reference this database from some other language, it's going
> to make little difference what backend you use; and even if you are
> using multiple languages, it's usually not difficult to find overlap.
Well this is python, but in the browser a little echo, instead of
print, isn't that bad for conversational php.

And in the end it's usually html, php, css, javascript in the browser,
atleast for me it is. I'm just starting to utilize python in that
area, so excuse the naivety.



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread zipher
You raise a valid point: that by abstracting the file pointer into a position 
attribute you risk "de-coupling" the conceptual link between the underlying 
file and your abstraction in the python interpreter, but I think the programmer 
can take responsibility for maintaining the abstraction.  

The key possible fault will be whether you can trap (OS-level) exceptions when 
assigning to the pos attribute beyond the bounds of the actual file on the 
system... 

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


Re: python file API

2012-09-24 Thread Dave Angel
(forwarding to the list)

On 09/24/2012 06:23 PM, Mark Adam wrote:
> On Mon, Sep 24, 2012 at 4:49 PM, Dave Angel  wrote:
>> On 09/24/2012 05:35 PM, zipher wrote:
>>> For some time now, I've wanted to suggest a better abstraction for the 
>>>  type in Python.  It currently uses an antiquated C-style interface 
>>> for moving around in a file, with methods like tell() and seek().  But 
>>> after attributes were introduced to Python, it seems it should be 
>>> re-addressed.
>>>
>>> Let file-type have an attribute .pos for position.   Now you can get rid of 
>>> the seek() and tell() methods and manipulate the file pointer more easily 
>>> with standard arithmetic operations.
>>>
>> file.pos = x0ae1  #move file pointer to an absolute address
>> file.pos +=1#increment the file pointer one byte
>> curr_pos = file.pos  #read current file pointer
> 
>> And what approach would you use for positioning relative to
>> end-of-file?  That's currently done with an optional second parameter to
>> seek() method.
> 
> As size is an oft-useful construct, let it (like .name) be part of the
> descriptor.  Then
> 
 file.pos = file.size - 80  #80 chars from end-of-file
> 
> (Or, one could make slices part of the API...)
> 
> mark
> 

Well, if one of the goals was to reduce the number of attributes, we're
now back to the original number of them.

-- 

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


Re: python file API

2012-09-24 Thread Ian Kelly
On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico  wrote:
> file.pos = 42 # Okay, you're at position 42
> file.pos -= 10 # That should put you at position 32
> foo = file.pos # Presumably foo is the integer 32
> file.pos -= 100 # What should this do?

Since ints are immutable, the language specifies that it should be the
equivalent of "file.pos = file.pos - 100", so it should set the file
pointer to 68 bytes before EOF.

> foo -= 100 # But this sets foo to the integer -68
> file.pos = foo # And this would set the file pointer 68 bytes from 
> end-of-file.

Which is the same result.

> I don't see it making sense for "file.pos -= 100" to suddenly put you
> near the end of the file; it should either cap and put you at position
> 0, or do what file.seek(-100,1) would do and throw an exception.

I agree, but the language doesn't allow those semantics.

Also, what about the use of `f.seek(0, os.SEEK_END)` to seek to EOF?
I'm not certain what the use cases are, but a quick google reveals
that this does happen in real code.  If a pos of 0 means BOF, and a
pos of -1 means 1 byte before EOF, then how do you seek to EOF without
knowing the file length?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
>> Out of curiosity, why? MySQL isn't magically better for everything
>> where data ends up displayed in a web browser.
>
> No, but phpmyadmin is a great GUI for MySQL
>
Meaning, it gives a great web app, that sqlite doesn't have...yet.
It's the tools around MySQL for me, that gives it the umph it needs to
be a great DB, with the GUI (phpmyadmin)to match, and short
reference/learni8ng curve to use php in this instance.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread Joshua Landau
On 24 September 2012 23:26, Dwight Hutto  wrote:

> On Mon, Sep 24, 2012 at 6:09 PM, Ethan Furman  wrote:
> > jimbo1qaz wrote:
> >>
> >> On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote:
> >>>
> >>> Am I missing something obvious, or do I have to manually put in a
> counter
> >>> in the for loops? That's a very basic request, but I couldn't find
> anything
> >>> in the documentation.
> >>
> >>
> >> Ya, they should really give a better way, but for now, enumerate works
> >> pretty well.
> >
> >
> > ROFLOL!!
> >
> > I look forward to the day when you look back on that statement and think,
> > "Wow, I've come a long way!"
> >
>
> It's a function usage. Not to be too serious, there are usually
> simpler solutions, and built in functions.
>
> But you usually sticks with what works, and seems timely in return of
> data output
>

This is not a criticism, but actual curiosity.

*How* would one implement this better, more simply (for the user, not the
implementator) or in a more readable manner?  Chose *any* one of those.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Chris Angelico
On Tue, Sep 25, 2012 at 8:31 AM, Dwight Hutto  wrote:
> And in the end it's usually html, php, css, javascript in the browser,
> atleast for me it is. I'm just starting to utilize python in that
> area, so excuse the naivety.

In the browser it's HTML, CSS, JavaScript (ECMAScript, etc, etc); PHP
is just a way of generating that. Any language works on the back
end... and PHP isn't the best :) Python does quite well at that task;
I have a tiny little Python script that uses a web browser as its
front ent.

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


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
> *How* would one implement this better, more simply (for the user, not the
> implementator) or in a more readable manner?  Chose *any* one of those.

Well if you're learning then the builtin might be more like how we
answer students questions here, than those doing work.

Write out the algorithmic function, and if you find one you can stuff
a few parameters in fine, but you still now how to do it by yourself
algorithmically.


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Oscar Benjamin
 On 24 September 2012 23:41, Mark Adam  wrote:

> > seek() and tell() can raise exceptions on some files. Exposing pos as an
> > attribute and allowing it to be manipulated with attribute access gives
> the
> > impression that it is always meaningful to do so.
>
> It's a good point, python already is allowing exceptions to be caught
> within "properties",  so exceptions from such an attribute could
> presumably be handled similarly.
>

There are many situations where a little bit of attribute access magic is a
good thing. However, operations that involve the underlying OS and that are
prone to raising exceptions even in bug free code should not be performed
implicitly like this. I find the following a little cryptic:
try:
f.pos = 256
except IOError:
print('Unseekable file')

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


Re: A little morning puzzle

2012-09-24 Thread Ian Kelly
On Mon, Sep 24, 2012 at 4:07 PM, Dwight Hutto  wrote:
> They stated:
>
> I have a list of dictionaries.  They all have the same keys.  I want to find 
> the
> set of keys where all the dictionaries have the same values.  Suggestions?
>
> No, to me it meant to find similar values in several dicts with the
> same key, and value. So I created several dicts, and some with the
> same key and value, and showed the matches.

Well, to me at least it is clear that when the OP writes "I want to
find the *set* of *keys*..." (emphasis added), then setting aside the
rest of the problem statement, the result of the algorithm should be a
set (or at least something set-like), and the contents of the set
should be keys.  The posted code produces neither a set nor any keys;
it prints out the same predetermined non-key value multiple times.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Chris Angelico
On Tue, Sep 25, 2012 at 8:37 AM, Ian Kelly  wrote:
> On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico  wrote:
>> file.pos = 42 # Okay, you're at position 42
>> file.pos -= 10 # That should put you at position 32
>> foo = file.pos # Presumably foo is the integer 32
>> file.pos -= 100 # What should this do?
>
> Since ints are immutable, the language specifies that it should be the
> equivalent of "file.pos = file.pos - 100", so it should set the file
> pointer to 68 bytes before EOF.

Oh, I forgot that guaranteed equivalency. Well, at least it removes
the ambiguity. I don't like it though.

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


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
> is just a way of generating that. Any language works on the back
> end... and PHP isn't the best :) Python does quite well at that task;
> I have a tiny little Python script that uses a web browser as its
> front ent.

This stems from my limited usage of python in the browser(I usually
use it for prototype apps). It's usually going to be the difference
between echo or print html/javascript, and perform an iteration for
table, or formulaic computation within a standard function syntax.


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Mark Lawrence

On 24/09/2012 22:35, zipher wrote:

For some time now, I've wanted to suggest a better abstraction for the  
type in Python.  It currently uses an antiquated C-style interface for moving around 
in a file, with methods like tell() and seek().  But after attributes were introduced 
to Python, it seems it should be re-addressed.

Let file-type have an attribute .pos for position.   Now you can get rid of the 
seek() and tell() methods and manipulate the file pointer more easily with 
standard arithmetic operations.


file.pos = x0ae1  #move file pointer to an absolute address
file.pos +=1#increment the file pointer one byte
curr_pos = file.pos  #read current file pointer


You've now simplified the API by the removal of two obscure legacy methods and replaced 
them with a more basic one called "position".

Thoughts?

markj



This strikes me as being a case of if it ain't broke don't fix it.

--
Cheers.

Mark Lawrence.

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


Re: A little morning puzzle

2012-09-24 Thread Dwight Hutto
The posted code produces neither a set nor any keys;
> it prints out the same predetermined non-key value multiple times.

This shows multiple dicts, with the same keys, and shows different
values, and some with the same, and that is, in my opinion what the OP
asked for:

a = {}
a['dict'] = 1

b = {}
b['dict'] = 2

c = {}
c['dict'] = 1

d = {}
d['dict'] = 3

e = {}
e['dict'] = 1


x = [a,b,c,d,e]
count = 0
collection_count = 0
search_variable = 1
for dict_key_search in x:
if dict_key_search['dict'] == search_variable:
print "Match count found: #%i = %i" % (count,search_variable)
collection_count += 1
count += 1
print collection_count



The OP can jump in and tell me to alter the example, if they want to.




-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Chris Kaynor
On Mon, Sep 24, 2012 at 3:37 PM, Ian Kelly  wrote:
> On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico  wrote:
>> file.pos = 42 # Okay, you're at position 42
>> file.pos -= 10 # That should put you at position 32
>> foo = file.pos # Presumably foo is the integer 32
>> file.pos -= 100 # What should this do?
>
> Since ints are immutable, the language specifies that it should be the
> equivalent of "file.pos = file.pos - 100", so it should set the file
> pointer to 68 bytes before EOF.

There is no reason that it has to be an int object, however. It could
well return a "FilePosition" object which does not allow subtraction
to produce a negative result. Not saying its a good idea... Similarly,
it could be a more complex object with properties on it to determine
whether to seek from beginning or end.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory usage per top 10x usage per heapy

2012-09-24 Thread Tim Chase
On 09/24/12 16:59, MrsEntity wrote:
> I'm working on some code that parses a 500kb, 2M line file line
> by line and saves, per line, some derived strings into various
> data structures. I thus expect that memory use should
> monotonically increase. Currently, the program is taking up so
> much memory - even on 1/2 sized files - that on 2GB machine I'm
> thrashing swap.

It might help to know what comprises the "into various data
structures".  I do a lot of ETL work on far larger files,
with similar machine specs, and rarely touch swap.

> 2) How can I diagnose (and hopefully fix) what's causing the
> massive memory usage when it appears, from heapy, that the code
> is performing reasonably?

I seem to recall that Python holds on to memory that the VM
releases, but that it *should* reuse it later.  So you'd get
the symptom of the memory-usage always increasing, never
decreasing.

Things that occur to me:

- check how you're reading the data:  are you iterating over
  the lines a row at a time, or are you using
  .read()/.readlines() to pull in the whole file and then
  operate on that?

- check how you're storing them:  are you holding onto more
  than you think you are?  Would it hurt to switch from a
  dict to store your data (I'm assuming here) to using the
  anydbm module to temporarily persist the large quantity of
  data out to disk in order to keep memory usage lower?

Without actual code, it's hard to do a more detailed
analysis.

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


Re: keeping information about players around

2012-09-24 Thread alex23
On Sep 25, 8:32 am, Dwight Hutto  wrote:
> No, but phpmyadmin is a great GUI for MySQL

If you're recommending MySQL use on the basis of phpmyadmin, you
should also make sure to mention:
http://www.phpmyadmin.net/home_page/security/

Great GUI, maybe. Huge security hole, absolutely. Most organisations
I've worked for won't allow it anywhere near their servers.


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


Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread alex23
On Sep 25, 6:04 am, Gelonida N  wrote:
> This all does not sound very comforting. Why is there no fix on the
> official site?

Has a bug been logged about the issue?

The Plone community keeps a fairly up-to-date fork called Pillow,
we've had a lot of success using that locally:

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


Re: For Counter Variable

2012-09-24 Thread alex23
On Sep 25, 8:58 am, Dwight Hutto  wrote:
> Well if you're learning then the builtin might be more like how we
> answer students questions here, than those doing work.

STOP SAYING THIS NONSENSE.

Using a pre-defined function is _not_ the "student" approach. Rolling
your own version of an existing function from scratch is _not_ the
"professional" approach.

If you're unable to realise this, then please stop dispensing advice
here like you know something.


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


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 7:28 PM, alex23  wrote:
> On Sep 25, 8:32 am, Dwight Hutto  wrote:
>> No, but phpmyadmin is a great GUI for MySQL
>
> If you're recommending MySQL use on the basis of phpmyadmin, you
> should also make sure to mention:
> http://www.phpmyadmin.net/home_page/security/
>
> Great GUI, maybe. Huge security hole, absolutely. Most organisations
> I've worked for won't allow it anywhere near their servers.
 What DB are you recommending, check out sqlite's:

http://www.cvedetails.com/vulnerability-list/vendor_id-9237/Sqlite.html

Maybe just a parsed file with data, and accessing data that you design.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
On Sep 25, 8:26 am, Dwight Hutto  wrote:
> It's a function usage. Not to be too serious, there are usually
> simpler solutions, and built in functions.

`enumerate` _is_ a built-in function. Please provide an example of a
"simpler solution".

It's not the simpler solution I'm referring to, it's the fact that if
you're learning, then you should be able to design the built-in, not
just use it.

You don't always know all the built-ins, so the builtin is simpler,
but knowing how to code it yourself is the priority of learning to
code in a higher level language, which should be simpler to the user
of python.

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread alex23
On Sep 25, 9:39 am, Dwight Hutto  wrote:
> It's not the simpler solution I'm referring to, it's the fact that if
> you're learning, then you should be able to design the built-in, not
> just use it.

Garbage. I don't need to be able to build a SQLAlchemy to use it. I
don't need to be able to build an XML parser to use one. The whole
goddamn point of abstractions is to _ease the cognitive load_ in
building a complex system.

> You don't always know all the built-ins, so the builtin is simpler,
> but knowing how to code it yourself is the priority of learning to
> code in a higher level language, which should be simpler to the user
> of python.

"Higher level" means, in part, not _having to give a shit_ about the
sort of low level coding you're obsessed with. If it rocks your world
to declare your own index pointer and increment it on each pass of a
loop, knock yourself out. Just accept that others will criticise your
code for being "unpythonic". Why even use the language if you're not
prepared to _use_ the language...and that means _more than the
syntax_. It extends to the standard library and through to the entire
ecosystem that has developed around it.

People are drawn to Python to get shit done, not to spend pointless
time in recreating every wheel.
-- 
http://mail.python.org/mailman/listinfo/python-list


which a is used?

2012-09-24 Thread Jayden
Dear All,

I have a simple code as follows:

# Begin
a = 1

def f():
print a

def g():
a = 20
f()

g()
#End

I think the results should be 20, but it is 1. Would you please tell me why?

Thanks a lot!

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


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
>> Well if you're learning then the builtin might be more like how we
>> answer students questions here, than those doing work.
>
> STOP SAYING THIS NONSENSE.
>
> Using a pre-defined function is _not_ the "student" approach.
What are talking about, I suggested they roll there own in several
responses this week.

Rolling
> your own version of an existing function from scratch is _not_ the
> "professional" approach.
Yes it is, if you don't know the builtin, and everyone has memory flaws.
> If you're unable to realise this, then please stop dispensing advice
> here like you know something.

Dude, you know jack shit, so go shovel this bullshit somewhere else,
where people aren't intelligent enough to read the rest of my posts


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 7:43 PM, Jayden  wrote:
> Dear All,
>
> I have a simple code as follows:
>
> # Begin
> a = 1
>
> def f():
> print a
>
> def g():
> a = 20
> f()
>
> g()
> #End
>
> I think the results should be 20, but it is 1. Would you please tell me why?
>
> Thanks a lot!
>
> --
> http://mail.python.org/mailman/listinfo/python-list

didn't return the value, or print it out


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
Propaganda over...

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory usage per top 10x usage per heapy

2012-09-24 Thread Junkshops

Hi Tim, thanks for the response.


- check how you're reading the data:  are you iterating over
   the lines a row at a time, or are you using
   .read()/.readlines() to pull in the whole file and then
   operate on that?
I'm using enumerate() on an iterable input (which in this case is the 
filehandle).



- check how you're storing them:  are you holding onto more
   than you think you are?
I've used ipython to look through my data structures (without going into 
ungainly detail, 2 dicts with X numbers of key/value pairs, where X = 
number of lines in the file), and everything seems to be working 
correctly. Like I say, heapy output looks reasonable - I don't see 
anything surprising there. In one dict I'm storing a id string (the 
first token in each line of the file) with values as (again, without 
going into massive detail) the md5 of the contents of the line. The 
second dict has the md5 as the key and an object with __slots__ set that 
stores the line number of the file and the type of object that line 
represents.



Would it hurt to switch from a
   dict to store your data (I'm assuming here) to using the
   anydbm module to temporarily persist the large quantity of
   data out to disk in order to keep memory usage lower?
That's the thing though - according to heapy, the memory usage *is* low 
and is more or less what I expect. What I don't understand is why top is 
reporting such vastly different memory usage. If a memory profiler is 
saying everything's ok, it makes it very difficult to figure out what's 
causing the problem. Based on heapy, a db based solution would be 
serious overkill.


-MrsE

On 9/24/2012 4:22 PM, Tim Chase wrote:

On 09/24/12 16:59, MrsEntity wrote:

I'm working on some code that parses a 500kb, 2M line file line
by line and saves, per line, some derived strings into various
data structures. I thus expect that memory use should
monotonically increase. Currently, the program is taking up so
much memory - even on 1/2 sized files - that on 2GB machine I'm
thrashing swap.

It might help to know what comprises the "into various data
structures".  I do a lot of ETL work on far larger files,
with similar machine specs, and rarely touch swap.


2) How can I diagnose (and hopefully fix) what's causing the
massive memory usage when it appears, from heapy, that the code
is performing reasonably?

I seem to recall that Python holds on to memory that the VM
releases, but that it *should* reuse it later.  So you'd get
the symptom of the memory-usage always increasing, never
decreasing.

Things that occur to me:

- check how you're reading the data:  are you iterating over
   the lines a row at a time, or are you using
   .read()/.readlines() to pull in the whole file and then
   operate on that?

- check how you're storing them:  are you holding onto more
   than you think you are?  Would it hurt to switch from a
   dict to store your data (I'm assuming here) to using the
   anydbm module to temporarily persist the large quantity of
   data out to disk in order to keep memory usage lower?

Without actual code, it's hard to do a more detailed
analysis.

-tkc


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


Re: keeping information about players around

2012-09-24 Thread alex23
On Sep 25, 9:44 am, Dwight Hutto  wrote:
>  What DB are you recommending, check out sqlite's:
>
> http://www.cvedetails.com/vulnerability-list/vendor_id-9237/Sqlite.html

Are you _seriously_ comparing _four_ vulnerabilities to 60+?

> Maybe just a parsed file with data, and accessing data that you design.

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


Re: For Counter Variable

2012-09-24 Thread alex23
On Sep 25, 9:49 am, Dwight Hutto  wrote:
> Rolling> your own version of an existing function from scratch is _not_ the
> > "professional" approach.
>
> Yes it is, if you don't know the builtin, and everyone has memory flaws.

Let me break this down for you in simple terms.

Code represents experience. Code that is considered important enough
to be in the standard library or as a built-in is something that
encapsulates a _lot_ of experience over time. You in your naive
approach to re-implement will _never capture that experience_. You'll
miss the edge cases that were already addressed. You'll over- or under-
extend the metaphor in ways the original doesn't.

And the first thing any experienced programmer would do when they
encountered your code is _refactor it to use the built-in_.

> Dude, you know jack shit, so go shovel this bullshit somewhere else,
> where people aren't intelligent enough to read the rest of my posts
> CEO: http://www.hitwebdevelopment.com

Is the animated GIF on your website under 60MB yet?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 7:57 PM, Dwight Hutto  wrote:
> On Mon, Sep 24, 2012 at 7:43 PM, Jayden  wrote:
>> Dear All,
>>
>> I have a simple code as follows:
>>
>> # Begin
>> a = 1
>>
>> def f():
>> print a
>>
>> def g():
>> a = 20
>> f()

this prints a from calling f() function

call print a wasn't in a class where it was self.a and changed, so it
performed the function f which prints a and a = 1, but g just assigns
the 20, and calls the f() function which shows a, there is no self.a,
nor a class to show this in.



>>
>> g()
>> #End
>>
>> I think the results should be 20, but it is 1. Would you please tell me why?
>>
>> Thanks a lot!
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
> didn't return the value, or print it out
>
>
> --
> Best Regards,
> David Hutto
> CEO: http://www.hitwebdevelopment.com



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Littlefield, Tyler

On 9/24/2012 3:14 PM, Dwight Hutto wrote:

I have yet another design question.
In my mud, zones are basically objects that manage a collection of rooms;
For example, a town would be it's own zone.
It holds information like maxRooms, the list of rooms as well as some other
data like player owners and access flags.
The access flags basically is a list holding the uid of a player, as well as
a bitarray of permissions on that zone. For example, a player might have the
ability to edit a zone, but not create rooms.
So I have a couple of questions based on this:
First, how viable would it be to keep a sort of player database around with
stats and that?



Well, what are the main items you need to retain for the player to
return to the game?



All of their contents are stored, which right now is done through Pickle. The 
stats is something different, as like I said, I don't want to unpickle an 
object every time I for example look at a zone and see what players have 
permissions on it.


Also, If this is a browser app I'd go with phpmyadmin, and MySQL If a 
tkinter/wxpython/etc app, then maybe sqlite.


PHPMyAdmin? Might I ask why? This is a mud, so it's all command based, 
so that's not even a question, but I'm kind of curious how PHPMyAdmin 
factors in there. It's a database creation tool from all I've ever seen 
of it, to define tables. Also, using it requires that I have it up on 
some server or another, and I'd really rather avoid that if I can.



It could contain the player's level, as well as other information like their
access (player, admin, builder etc), and then when someone does a whois on
the player I don't have to load that player up just to get data about them.
How would I keep the information updated? When I delete a player, I could
just delete the entry from the database by uid.
Second, would it be viable to have both the name and the uid stored in the
dictionary? Then I could look up by either of those?


Why would you use a dictionary, when it's DB manipulation you're after?



It is? I don't remember mentioning database anything in my thread. Unless I 
missed it, I mentioned pickle once or twice. But either way, I'd use a 
dictionary to keep a copy of {uid:object} for objects and {uid:player} for 
players. Makes lookup by uid pretty easy, as well as for any loaded objects.



Also, I have a couple more general-purpose questions relating to the mud.
When I load a zone, a list of rooms get stored on the zone, as well as
world. I thought it might make sense to store references to objects located
somewhere else but also on the world in WeakValueDictionaries to save
memory. It prevents them from being kept around (and thus having to be
deleted from the world when they lose their life), but also (I hope) will
save memory. Is a weakref going to be less expensive than a full reference?

For any case, you're going to have a DB field with a value, so it
doesn't look like a high value memory cost in the DB.


Second, I want to set up scripting so that you can script events for rooms
and npcs. For example, I plan to make some type of event system, so that
each type of object gets their own events. For example, when a player walks
into a room, they could trigger some sort of trap that would poison them.
This leads to a question though: I can store scripting on objects or in
separate files, but how is that generally associated and executed?

Well, the event doesn't need to be stored unless there is a necessity
to store the event, but if it's poisoned, then it's just a life
penalty, then no need to store the event, just the score loss.



I was asking about scripting the rooms, more than storing it. I need to have 
python code somewhere, somehow that attaches to the onEnter event in a room and 
subtracts hp from the player. Obviously you want that to be object specific and 
not have that script on everything.



Finally, I just want to make sure I'm doing things right. When I store data,
I just pickle it all, then load it back up again. My world object has an
attribute defined on it called picklevars, which is basically a list of
variables to pickle, and my __getstate__ just returns a dictionary of those.
All other objects are left "as-is" for now. Zones, (the entire zone and all
it's rooms) get pickled, as well as players and then the world object for
persistence. Is this the suggested way of doing things? I'll also pickle the
HelpManager object, which will basically contain a list of helpfiles that

I might suggest you take a look at the Blender Game Engine(python API)
at this point, unless you're just liking doing it the hard way to gain
experience(just like I have).



That's cool I guess, but I'm not taking your road and doing it the hard way for 
experience. The setup is more of a game engine, but beyond that, I don't think 
I need everything i get from a game library, especially since IIRC, Blender is 
mainly 3d focused?


Design the DB, and let the scene render what needs to be rendered, or 
list d

Re: which a is used?

2012-09-24 Thread alex23
On Sep 25, 9:43 am, Jayden  wrote:
> Dear All,
>
> I have a simple code as follows:
>
> # Begin
> a = 1
>
> def f():
>     print a
>
> def g():
>     a = 20
>     f()
>
> g()
> #End
>
> I think the results should be 20, but it is 1. Would you please tell me why?

Because you don't declare 'a' in 'f', it looks for 'a' in the
surrounding scope _where it was defined_, not where it was called.
Because 'a' in the module scope is 1, you'll get 1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread alex23
On Sep 25, 10:18 am, Dwight Hutto  wrote:
> what's the fucking point of that question

To highlight the vast gulf between what you think you are and what you
actually produce.


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


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
> Is the animated GIF on your website under 60MB yet?
yeah a command line called convert, and taking out a few jpegs used to
convert, and I can reduce it to any size, what's the fucking point of
that question other than ignorant rhetoric, that you know is easily
fixable?


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
> To highlight the vast gulf between what you think you are and what you
> actually produce.

I produce working code, and if it works, then I don't just think...I know.



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: keeping information about players around

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 7:52 PM, alex23  wrote:
> On Sep 25, 9:44 am, Dwight Hutto  wrote:
>>  What DB are you recommending, check out sqlite's:
>>
>> http://www.cvedetails.com/vulnerability-list/vendor_id-9237/Sqlite.html
>
> Are you _seriously_ comparing _four_ vulnerabilities to 60+?
>
Even less if you use your own DB structure, and evn less in mysql if
you reject the injections of the known vulnerablities.

>> Maybe just a parsed file with data, and accessing data that you design.
>
> Just stop.

Why not suggest odbm or relational db's, this shows your lack of
complexity in design, so please stop your own Dunner-Kruning.



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread cjgohlke
On Monday, September 24, 2012 4:38:05 PM UTC-7, alex23 wrote:
> On Sep 25, 6:04 am, Gelonida N  wrote:
> 
> > This all does not sound very comforting. Why is there no fix on the
> 
> > official site?
> 
> 
> 
> Has a bug been logged about the issue?
> 

See issue #1 at 


Christoph

> 
> 
> The Plone community keeps a fairly up-to-date fork called Pillow,
> 
> we've had a lot of success using that locally:
> 
> 
> 
> http://pypi.python.org/pypi/Pillow/

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


Re: For Counter Variable

2012-09-24 Thread Oscar Benjamin
On 25 September 2012 01:17, Dwight Hutto  wrote:

> > Is the animated GIF on your website under 60MB yet?
> yeah a command line called convert, and taking out a few jpegs used to
> convert, and I can reduce it to any size, what's the fucking point of
> that question other than ignorant rhetoric, that you know is easily
> fixable?


Calm down! I don't want to read you to abusing and baiting each other.

If you do both mutually consent to continuing this conversation then do it
off list.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: For Counter Variable

2012-09-24 Thread Littlefield, Tyler

On 9/24/2012 6:25 PM, Dwight Hutto wrote:

To highlight the vast gulf between what you think you are and what you
actually produce.

I produce working code, and if it works, then I don't just think...I know.

Working code != good code. Just an observation. Also, I've noticed a vast differences 
between someone who can explain their answers as Alix has done on multiple threads you've 
replied to in the last 5 minutes, and someone who cobbles something together with 
"your variable isn't being shown right because there's no self.a," which 
actually really makes no sense at all. Just my $0.02.


--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

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


Re: For Counter Variable

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 8:32 PM, Littlefield, Tyler  wrote:
> On 9/24/2012 6:25 PM, Dwight Hutto wrote:
>>>
>>> To highlight the vast gulf between what you think you are and what you
>>> actually produce.
>>
>> I produce working code, and if it works, then I don't just think...I know.
>>
>> Working code != good code. Just an observation. Also, I've noticed a vast
>> differences between someone who can explain their answers as Alix has done
>> on multiple threads you've replied to in the last 5 minutes, and someone who
>> cobbles something together with "your variable isn't being shown right
I might have mispoke, forgive me for knowing several languages,and
getting a little class syntax wrong,. It's called computer science and
interdisciplinary study you dumb fucking double digit IQ'd twit.


>> because there's no self.a," which actually really makes no sense at all.

That was in a class scenario

>> Just my $0.02.
>
>
> --
> Take care,
> Ty
> http://tds-solutions.net
> The aspen project: a barebones light-weight mud engine:
> http://code.google.com/p/aspenmud
> He that will not reason is a bigot; he that cannot reason is a fool; he that
> dares not reason is a slave.
>
> --
> http://mail.python.org/mailman/listinfo/python-list



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread Dwight Hutto
Anything else bitch, take time to think about it.
-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory usage per top 10x usage per heapy

2012-09-24 Thread Dave Angel
On 09/24/2012 05:59 PM, MrsEntity wrote:
> Hi all,
>
> I'm working on some code that parses a 500kb, 2M line file 

Just curious;  which is it, two million lines, or half a million bytes?

> line by line and saves, per line, some derived strings into various data 
> structures. I thus expect that memory use should monotonically increase. 
> Currently, the program is taking up so much memory - even on 1/2 sized files 
> - that on 2GB machine 

which machine is 2gb, the Windows machine, or the VM?  You could get
thrashing at either level.

> I'm thrashing swap. What's strange is that heapy 
> (http://guppy-pe.sourceforge.net/) is showing that the code uses about 10x 
> less memory than reported by top, and the heapy data seems consistent with 
> what I was expecting based on the objects the code stores. I tried using 
> memory_profiler (http://pypi.python.org/pypi/memory_profiler) but it didn't 
> really provide any illuminating information. The code does create and discard 
> a number of objects per line of the file, but they should not be stored 
> anywhere, and heapy seems to confirm that. So, my questions are:
>
> 1) For those of you kind enough to help me figure out what's going on, what 
> additional data would you like? I didn't want swamp everyone with the code 
> and heapy/memory_profiler output but I can do so if it's valuable.
> 2) How can I diagnose (and hopefully fix) what's causing the massive memory 
> usage when it appears, from heapy, that the code is performing reasonably?
>
> Specs: Ubuntu 12.04 in Virtualbox on Win7/64, Python 2.7/64
>
> Thanks very much.

Tim raised most of my concerns, but I would point out that just because
you free up the memory from the Python doesn't mean it gets released
back to the system.  The C runtime manages its own heap, and is pretty
persistent about hanging onto memory once obtained.  It's not normally a
problem, since most small blocks are reused.  But it can get
fragmented.  And i have no idea how well Virtual Box maps the Linux
memory map into the Windows one.



-- 

DaveA

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


Re: For Counter Variable

2012-09-24 Thread Paul Rubin
alex23  writes:
> To highlight the vast gulf between what you think you are and what you
> actually produce.

By now I think we're in the DNFTT zone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread Steven D'Aprano
On Mon, 24 Sep 2012 16:43:24 -0700, Jayden wrote:

> Dear All,
> 
> I have a simple code as follows:
> 
> # Begin
> a = 1
> 
> def f():
> print a
> 
> def g():
> a = 20
> f()
> 
> g()
> #End
> 
> I think the results should be 20, but it is 1. Would you please tell me
> why?

You are expecting "dynamic scoping", Python uses "static scoping" (or 
lexical scoping). With lexical scoping, you can reason about the 
behaviour of a function by knowing only how and where it is defined. The 
caller is irrelevant.

Since function f is defined globally, and does not have its own local 
variable a, it will always see the global variable a no matter where it 
is called. So when you call f() from inside g(), f prints 1, the global 
a, not 20, g's local a.

While dynamic scoping has its uses, it is more tricky to use correctly. 
One can no longer understand the behaviour of a function just by reading 
the function's own code, knowing where and how it is defined. You also 
need to know where it is called. A function f that works perfectly when 
you call it from functions g, h, k, ... will suddenly misbehave (crash, 
or worse, behave wrongly) when called from function v because v 
accidentally changes some global variable that f relies on.

This is especially a danger for Python, because built-in functions like 
len, chr, ord, print (version 3 only), and many others are all global 
variables.

(Technically, they are in a third scope, the builtins, but that's 
equivalent to being global.)



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


Who's laughing at my responses, and who's not?

2012-09-24 Thread Dwight Hutto
Been getting slammed by a few for some insignificant things, so who's
laughing at me, and who takes me seriously. I don't claim to be the
best, just trying to help.

So who doesn't want me around?

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Steven D'Aprano
On Tue, 25 Sep 2012 08:14:01 +1000, Chris Angelico wrote:

> Presumably the same way you reference a list element relative to
> end-of-list: negative numbers. However, this starts to feel like magic
> rather than attribute assignment - it's like manipulating the DOM in
> JavaScript, you set an attribute and stuff happens. Sure it's legal, but
> is it right? Also, it makes bounds checking awkward:
> 
> file.pos = 42 # Okay, you're at position 42 
> file.pos -= 10 # That should put you at position 32 
> foo = file.pos # Presumably foo is the integer 32
> file.pos -= 100 # What should this do? 
> foo -= 100 # But this sets foo to the integer -68 
> file.pos = foo # And this would set the file pointer 68 bytes
> from end-of-file.
> 
> I don't see it making sense for "file.pos -= 100" to suddenly put you
> near the end of the file; it should either cap and put you at position
> 0, or do what file.seek(-100,1) would do and throw an exception.

I would expect it to throw an exception, like file.seek and like list 
indexing.

> But
> doing the exact same operation on a saved snapshot of the position and
> reassigning it would then have quite different semantics in an unusual
> case, while still appearing identical in the normal case.

But this applies equally to file.seek and list indexing today. In neither 
case can you perform your own index operations outside of the file/list 
and expect to get the same result, for the simple and obvious reason that 
arithmetic doesn't perform the same bounds checking as actual seeking and 
indexing.

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


Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread Alex Clark

On 2012-09-24 23:38:05 +, alex23 said:


On Sep 25, 6:04 am, Gelonida N  wrote:

This all does not sound very comforting. Why is there no fix on the
official site?


Has a bug been logged about the issue?

The Plone community keeps a fairly up-to-date fork called Pillow,
we've had a lot of success using that locally:

http://pypi.python.org/pypi/Pillow/



Actually, I started it for the Plone community, but have recently 
broadened the scope (since most of the contributions came from outside 
Plone). It now lives here:


- https://github.com/python-imaging/Pillow


If you have any trouble using it, please open a ticket here:

- https://github.com/python-imaging/Pillow/issues



Alex



--
Alex Clark · http://pythonpackages.com


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


Re: which a is used?

2012-09-24 Thread Dwight Hutto
On Mon, Sep 24, 2012 at 9:18 PM, Steven D'Aprano
 wrote:
> On Mon, 24 Sep 2012 16:43:24 -0700, Jayden wrote:
>
>> Dear All,
>>
>> I have a simple code as follows:
>>
>> # Begin
>> a = 1
>>
>> def f():
>> print a
>>Paul Rubin 
>> def g():
>> a = 20
>> f()
>>
>> g()
>> #End
>>
>> I think the results should be 20, but it is 1. Would you please tell me
>> why?
>
> You are expecting "dynamic scoping", Python uses "static scoping" (or
> lexical scoping). With lexical scoping, you can reason about the
> behavioPaul Rubin ur of a function by knowing only 
> how and where it is defined. The
> caller is irrelevant.
>
> Since fuPaul Rubin nction f is defined globally, and 
> does not have its own local
> variable a, it will always see the global variable a no matter where it
> is called. So when you call f() from inside g(), f prints 1, the global
> a, not 20, g's local a.
>
> While dynamic scoping has its uses, it is more tricky to use correctly.
> One can no longer understand the behaviour of a function just by reading
> the funcPaul Rubin tion's own code, knowing where 
> and how it is defined. You also
> need to know where it is called. A function f that works perfectly when
> you call it from functions g, h, k, ... will suddenly misbehave (crash,
> or worse, behave wrongly) when called from function v because v
> accidentally changes some global variable that f relies on.
>
> This is especially a danger for Python, because built-in functions like
> len, chr, ord, print (version 3 only), and many others are all global
> variables.
>
> (Technically, they are in a third scope, the builtins, but that's
> equivalent to being global.)
>

But within a class this is could be defined as self.x within the
functions and changed, correct?


class a():
def __init__(self,a):
self.a = a

def f(self):
print self.a

def g(self):
self.a = 20
print self.a


a = a(1)
a.f()
a.g()


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



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread Dwight Hutto
But within a class this is could be defined as self.x within the
functions and changed, correct?


class a():
def __init__(self,a):
self.a = a

def f(self):
print self.a

def g(self):
self.a = 20
print self.a


a = a(1)
a.f()
a.g()


Yielding:

david@david-desktop:~$ python answer_to_email.py
1
20
david@david-desktop:~$


-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread alex23
On Sep 25, 6:04 am, Gelonida N  wrote:
> So I'll probably try to install the custom binary, but would like to
> know whether anybody has experience with this
> build.http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

Sorry, I missed this the first time. I'm using this version
successfully under Windows 7 64-bit. I've had nothing but success with
extensions I've used from that site.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL questions: still supported? Problems on 2.7 for win? alternatives?

2012-09-24 Thread alex23
On Sep 25, 11:46 am, Alex Clark  wrote:
> Actually, I started it for the Plone community, but have recently
> broadened the scope (since most of the contributions came from outside
> Plone).

You're a saint, thanks for taking this on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which a is used?

2012-09-24 Thread alex23
On Sep 25, 11:13 am, Dwight Hutto  wrote:
> bitch

I honestly could not care less what you think about me, but don't use
that term. This isn't a boys' club and we don't need your hurt ego
driving people away from here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python file API

2012-09-24 Thread Steven D'Aprano
On Mon, 24 Sep 2012 15:36:20 -0700, zipher wrote:

> You raise a valid point: that by abstracting the file pointer into a
> position attribute you risk "de-coupling" the conceptual link between
> the underlying file and your abstraction in the python interpreter

I don't think this argument holds water. With the ease of writing 
attributes, it is more likely that people will perform file position 
operations directly on file.pos rather than decoupling it into a 
variable. Decoupling is more likely with file.seek, because it is so much 
more verbose to use, and you get exactly the same lack of bounds checking:

py> f = open("junk", "w")  # make a sample file
py> f.write("abcd\n")
py> f.close()
py> f = open("junk")  # now do decoupled seek operations
py> p = f.tell()
py> p += 2000
py> p -= 4000
py> p += 2
py> p += 2000
py> f.seek(p)
py> f.read(1)
'c'


But really, who does such a sequence of arithmetic operations on the file 
pointer without intervening reads or writes? We're arguing about 
something that almost never happens.

By the way, the implementation of this is probably trivial in Python 2.x. 
Untested:

class MyFile(file):
@property
def pos(self):
return self.tell()
@pos.setter
def pos(self, p):
if p < 0:
self.seek(p, 2)
else:
self.seek(p)

You could even use a magic sentinel to mean "see to EOF", say, None.

if p is None:
self.seek(0, 2)

although I don't know if I like that.



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


Re: keeping information about players around

2012-09-24 Thread Steven D'Aprano
On Tue, 25 Sep 2012 08:19:34 +1000, Chris Angelico wrote:

> On Tue, Sep 25, 2012 at 7:14 AM, Dwight Hutto 
> wrote:
>> Also, If this is a browser app I'd go with phpmyadmin, and MySQL
>>
>> If a tkinter/wxpython/etc app, then maybe sqlite.
> 
> Out of curiosity, why? MySQL isn't magically better for everything where
> data ends up displayed in a web browser. Unless you're planning to also
> reference this database from some other language, it's going to make
> little difference what backend you use; and even if you are using
> multiple languages, it's usually not difficult to find overlap.

For a desktop application, you can't expect the application user to have 
set up MySQL or Postgresql first, so you have to use something like 
sqlite.

For web applications, you're probably expecting (or at least hoping for) 
tens of thousands of users a day, and sqlite probably won't cut it. If 
your web app is only used by you, then you might not care.

I think it is perfectly reasonable to assume a web app and a desktop app 
might use different backends.



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


Re: python file API

2012-09-24 Thread Mark Adam
On Mon, Sep 24, 2012 at 5:55 PM, Oscar Benjamin
 wrote:
> There are many situations where a little bit of attribute access magic is a
> good thing. However, operations that involve the underlying OS and that are
> prone to raising exceptions even in bug free code should not be performed
> implicitly like this. I find the following a little cryptic:
> try:
> f.pos = 256
> except IOError:
> print('Unseekable file')

Well it might be that the coupling between the python interpreter and
the operating system should be more direct and there should be a
special exception class that bypasses the normal overhead in the
CPython implementation so that error can be caught in the code without
breaking syntax.  But I don't think I'm ready to argue that point

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


Re: which a is used?

2012-09-24 Thread Dwight Hutto
> I honestly could not care less what you think about me, but don't use
> that term. This isn't a boys' club and we don't need your hurt ego
> driving people away from here.

OH. stirrin up shit and can't stand the smell. Turn and
switch technique. "You're so vulgar, and I wasn't."Go get a clue ho,
and then you can gumshoe it up the last crack alley on the left, and
suck till my nut hair tickles your tonsils.




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



-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
-- 
http://mail.python.org/mailman/listinfo/python-list


"9/11 Missing Links" is the video that Jews do not want you to see!

2012-09-24 Thread Suzi Mrezutttii
Google and watch "9/11 Missing Links" before Jews remove it from
youtube anytime now!


http://joozhatetruth.blogspot.com/

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


Re: "9/11 Missing Links" is the video that Jews do not want you to see!

2012-09-24 Thread hamilton

On 9/24/2012 9:35 PM, Suzi Mrezutttii wrote:

Google and watch "9/11 Missing Links" before Jews remove it from
youtube anytime now!





Hey dude, Nice name, "a boy named sue" !!!
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >