Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Aseem Bansal
@Andrew Berg
@Chris Angelico

Is there a way to have both Python 2 and 3 installed on my computer till I can 
update the little codebase that I have built? Can I make different commands for 
invoking python 2 and Python 3? I am using Windows 7 and use Windows Powershell 
as an alternative to the linux terminal. Any suggestions about how to do that 
instead of breaking all my code at once?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Chris Angelico
On Thu, Jul 18, 2013 at 5:05 PM, Aseem Bansal  wrote:
> @Andrew Berg
> @Chris Angelico
>
> Is there a way to have both Python 2 and 3 installed on my computer till I 
> can update the little codebase that I have built? Can I make different 
> commands for invoking python 2 and Python 3? I am using Windows 7 and use 
> Windows Powershell as an alternative to the linux terminal. Any suggestions 
> about how to do that instead of breaking all my code at once?

Yep! And in fact, Python 3.3 includes a launcher that makes it fairly
easy. Just install another version, and then check this out:

http://docs.python.org/3.3/using/windows.html#launcher

You can use a Unix-style shebang to specify which Python version some
script depends on.

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


Re: tkinter redraw rates

2013-07-18 Thread Christian Gollwitzer

Am 18.07.13 06:38, schrieb [email protected]:

On Thursday, July 18, 2013 9:07:24 AM UTC+8, Dave Angel wrote:

Nope - don't use that.  Instead, post an event on the queue, and return
to the mainloop() from whence we came.
  def test_thread(self):
 if self.loader_thread.isAlive():
 self.root_window.after(100, self.test_thread)
 return





I see, though it should be noted that your method doesn't actually
block the rest of the even handler code from running, had to fiddle
with it a bit to get that to work. May I ask what exactly is the
rationale behind implementing it like this, though?



Exactly this is the goal of it. Event handlers are supposed to run in as 
short time as possible, and should never block. The reason is that you 
want the events to be processed in the order they come in, such that he 
user can still move the window, resize it, iconify/maximize etc.


That said, the code still looks odd to me. I have used the Tk with 
multithreading in the past, but directly from Tcl, and not from Python.
The basic idea is to have the background thread (which does the work) 
signal the main thread about its status, i.e. in the worker thread:


for i in range(50):
  some_odd_computation()
  signal('progress', i)

signal('finished')

and in the main thread you bind() to the events fired from the worker 
thread. That way you don't run any periodic polling.


I fear that Tkinter has a shortcoming which does not allow this pattern 
to be implemented. The tricky thing is to implement this signal() 
function, which must post an event to another thread. From the C level, 
there is Tcl_ThreadQueueEvent() which does this. It arranges for a C 
function to be run from the event loop of another thread. From Tcl, 
thread::send does this. To use it from Tkinter, it would be necessary to 
create a Tcl interpreter in the worker thread *without* loading Tk.


Some day I should dive into the innards of Tkinter to see if this is 
possible. Then you could implement signal() simply by


def signal(sig, data=''):
	tclinterp.eval('thread::send -async $mainthread {event generate . 
<<%s>> -data {%s}'%sig%data)


and in the main thread bind() to the virtual events.

Christian


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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Aseem Bansal
@ChrisA

Thanks. That's great. That solved the whole thing easily. I'll install Python 3 
and start updating today.

About reading comp.lang.python can you suggest how to read it and reply? I have 
never read a newsgroup leave alone participated in one. I am used to forums 
like stackoverflow. Any way to read it and reply by one interface? If not, give 
any suggestion. I'll use that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Chris Angelico
On Thu, Jul 18, 2013 at 5:29 PM, Aseem Bansal  wrote:
> @ChrisA
>
> Thanks. That's great. That solved the whole thing easily. I'll install Python 
> 3 and start updating today.
>
> About reading comp.lang.python can you suggest how to read it and reply? I 
> have never read a newsgroup leave alone participated in one. I am used to 
> forums like stackoverflow. Any way to read it and reply by one interface? If 
> not, give any suggestion. I'll use that.

Easiest, if you're not familiar with newsgroups, is to subscribe to
the mailing list.

Subscribe here:

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

Then you get an email every time anyone posts. Threading should be
handled by any decent mail client, and you just hit Reply-List (or
Reply and change the address to [email protected]) to post a
follow-up.

It's a good system. Works for myriad lists. The software that runs
this one (Mailman) is even written in Python, so you're using Python
to discuss Python :)

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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Aseem Bansal
@ChrisA

I subscribed to it. How do I reply to a message that has already been posted 
before my subscription?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Chris Angelico
On Thu, Jul 18, 2013 at 5:48 PM, Aseem Bansal  wrote:
> @ChrisA
>
> I subscribed to it. How do I reply to a message that has already been posted 
> before my subscription?

Not easily, far as I know. But you now have this reply, and you can
always just post something with the right subject line and hope that
people pick up that it's part of the same discussion topic. Transition
isn't the cleanest but once it's done it's done.

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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Aseem Bansal
I tried replying to your message by mail. I used the reply button and send it 
to "[email protected]"? Or do I need to use "[email protected]" as you 
wrote in your post?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Chris Angelico
On Thu, Jul 18, 2013 at 6:10 PM, Aseem Bansal  wrote:
> I tried replying to your message by mail. I used the reply button and send it 
> to "[email protected]"? Or do I need to use "[email protected]" as you 
> wrote in your post?

You replied correctly. The ellipsis was presumably an anti-spam
feature. Send to python-list at python dot org to post.

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


Re: Stack Overflow moderator “animuson”

2013-07-18 Thread Antoine Pitrou
Joshua Landau  landau.ws> writes:
> 
> > The same with Unicode. We hate French people,
> 
> And for good damn reason too. They're ruining our language, á mon avis.

We do!


Regards

Antoine.


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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Joshua Landau
On 18 July 2013 00:58, CTSB01  wrote:
> Please let me know if this is unclear.  I will certainly continue revising 
> until it makes sense to those reading.

Can you summarize what your question is? Leave aside the details of
the function, just explain what thing in particular you aren't able
to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter redraw rates

2013-07-18 Thread fronagzen
On Thursday, July 18, 2013 3:20:28 PM UTC+8, Christian Gollwitzer wrote:
> Am 18.07.13 06:38, schrieb [email protected]:
> > On Thursday, July 18, 2013 9:07:24 AM UTC+8, Dave Angel wrote:
> >> Nope - don't use that.  Instead, post an event on the queue, and return
> >> to the mainloop() from whence we came.
> >>   def test_thread(self):
> >>  if self.loader_thread.isAlive():
> >>  self.root_window.after(100, self.test_thread)
> >>  return
> > I see, though it should be noted that your method doesn't actually
> > block the rest of the even handler code from running, had to fiddle
> > with it a bit to get that to work. May I ask what exactly is the
> > rationale behind implementing it like this, though?
> Exactly this is the goal of it. Event handlers are supposed to run in as 
> short time as possible, and should never block. The reason is that you 
> want the events to be processed in the order they come in, such that he 
> user can still move the window, resize it, iconify/maximize etc.
> That said, the code still looks odd to me. I have used the Tk with 
> multithreading in the past, but directly from Tcl, and not from Python.
> The basic idea is to have the background thread (which does the work) 
> signal the main thread about its status, i.e. in the worker thread:
> for i in range(50):
>some_odd_computation()
>signal('progress', i)
> signal('finished')
> and in the main thread you bind() to the events fired from the worker 
> thread. That way you don't run any periodic polling.
> I fear that Tkinter has a shortcoming which does not allow this pattern 
> to be implemented. The tricky thing is to implement this signal() 
> function, which must post an event to another thread. From the C level, 
> there is Tcl_ThreadQueueEvent() which does this. It arranges for a C 
> function to be run from the event loop of another thread. From Tcl, 
> thread::send does this. To use it from Tkinter, it would be necessary to 
> create a Tcl interpreter in the worker thread *without* loading Tk.
> Some day I should dive into the innards of Tkinter to see if this is 
> possible. Then you could implement signal() simply by
> def signal(sig, data=''):
>   tclinterp.eval('thread::send -async $mainthread {event generate . 
> <<%s>> -data {%s}'%sig%data)
> and in the main thread bind() to the virtual events.
>   Christian
Ah, I see. Thank you for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why on CentOS, python consumes too much memory ?

2013-07-18 Thread William Bai
I found that it was caused by not by python but by 
/usr/lib/locale/locale-archive, the same problem as that described in
http://illiterat.livejournal.com/4615.html.

William

在 2013年7月18日星期四UTC+8下午12时45分01秒,William Bai写道:
> Hi:
> 
> 
> 
>Previously, we found that our python scripts consume too much memory. So I 
> use python's resource module to restrict RLIMIT_AS's soft limit and hard 
> limit to 200M.
> 
> On my RHEL5.3(i386)+python2.6.2, it works OK. But on CentOS 
> 6.2(x86_64)+python2.6.6, it reports memory error(exceeding 200M).
> 
> 
> 
> And I tested with a very small script, and result is out of my expect, it 
> still use too much memory on my CentOS 6.2 python:
> 
> import time
> 
> time.sleep(200)
> 
> 
> 
> I use guppy and memory_profiler to see the memory usage and see that 
> python objects just use about 6M memory both on RHEL5.3(i386)+python2.6 and 
> CentOS 6.2(x86_64)+python2.6. But when I cat /proc//status. I found that 
> though VmRss is not very large on both machines. But the VmSize on CentOS 
> 6.2(x86_64)+python2.6 is 140M-180M, while on my RHEL5.3+python2.6, the VmSize 
> is just 6M. And I tested on CentOS 5.7(x86_64)+python2.4.3, the VmSize is 70M.
> 
> 
> 
>  I could understand that 64 bit machines will occupy more virtual memory 
> than that on 32 bit, because the length of some types are not the same. But I 
> don't know why they differs so greatly(6M to 180M), Or is this only caused by 
> that python2.6 on CentOS 6.2's memory allocation is different from python's 
> default one? Could you kindly give me some clues? Thank you very much.
> 
> 
> 
> Best Regards
> 
> William

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


Re: Why on CentOS, python consumes too much memory ?

2013-07-18 Thread Antoine Pitrou
 gmail.com> writes:
> 
> Hi:
> 
>Previously, we found that our python scripts consume too much memory.
So I use 
python's resource module to
> restrict RLIMIT_AS's soft limit and hard limit to 200M.
> On my RHEL5.3(i386)+python2.6.2, it works OK. But on CentOS 
6.2(x86_64)+python2.6.6, it reports memory
> error(exceeding 200M).

Take a look at http://www.selenic.com/smem/ for accurate measurement of
actual memory consumption under Linux. Virtual memory size is generally
useless for this purpose.

Regards

Antoine.


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


Re: Homework help requested (not what you think!)

2013-07-18 Thread Beth McNany
On Tue, Jul 16, 2013 at 6:43 PM, John Ladasky wrote:

> Hi folks,
>
> No, I'm not asking for YOU to help ME with a Python homework assignment!
>
> Previously, I mentioned that I was starting to teach my son Python.
>
> https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ
>
> He just took a course at his high school called Web Technology and Design.
>  They had the students use tools like Dream Weaver, but they also
> hand-coded some HTML and JavaScript.  He has a little experience.  I am
> building on it.
>
> Well, a few other parents caught wind of what I was doing with my son, and
> they asked me whether I could tutor their kids, too.  I accepted the jobs
> (for pay, actually).
>
> The kids all claim to be interested.  They all want to write the next
> great 3D video game.  Thus, I'm a little surprised that the kids don't
> actually try to sit down and code without me prompting them.  I think that
> they're disappointed when I show them how much they have to understand just
> to write a program that plays Tic Tac Toe.
>
> Where programming is concerned, I'm an autodidact.  I started programming
> when I was twelve, with little more guidance than the Applesoft Basic
> manual and the occasional issue of Byte Magazine.  I hacked away.  Over the
> years, I have acquired a working knowledge of BASIC, 6502 assembly
> language, Pascal, C, and finally Python (my favorite).  If I knew how to
> impart a love of experimentation to my students, I would do that.
>
> One kid looks like he's ready to forge ahead.  In the mean time, one
> parent has recognized his son's lack of independence, and has asked me to
> assign programming homework.  I hope it doesn't kill the kid's enthusiasm,
> but I'm willing to try it.
>
> So, what I am seeking are suggestions for programming assignments that I
> can give to brand-new students of Python.  Please keep in mind that none of
> them are even up to the task of a simple algorithm like Bubble Sort -- at
> least, not yet.
>
> Many thanks!
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Thanks for this!  I'm trying to put together something very similar right
now for my younger brother, and this thread and associated links have been
very helpful.  He's taught himself enough Python to make a rudimentary text
adventure game already, so the interest is definitely there.  I'm hoping to
sneak in some general CS concepts as well, although I'm concerned some
things might be less obvious in Python.  Also, I learned to program in PHP
and Java before I learned Python (starting with a Django project), so I'm
not sure how to start there... probably going to borrow some ideas from the
intro level Java class I've been TA'ing.

In my experience, people learn best via projects, so I've been trying to
come up with some that are interesting, not too difficult, and focus on one
or two main concepts.  To be honest, I have no idea how realistic they are,
because it's been a while since I first learned how to program and that
wasn't even in Python.  Offering it up here for your perusal / feedback
(roughly in the order I'd do them):

- text adventure: practice with stdlib, control flow, I/O. Lots of
opportunities for embellishment here - create maps of rooms, load/save
games by serializing into files or even a database, create status bars in
the console, etc.

- blackjack:  a game with simple rules, you have to think about
representation for the cards, and you can easily simulate a computer
opponent.  extra credit: graphical front-end that displays images for the
cards.

- sudoku checker/generator/solver: practice with lists, loops, logic,
implementing algorithms.  extra credit: design a solver yourself without
looking up algorithms.

- mandelbrot set app: math and graphics! can use this as an opportunity to
introduce numpy/matplotlib, or DIY.  (could be a bit esoteric depending on
the student, though.)

- game of life: simple graphics and update rules, fun to watch, source of
the unofficial hacker emblem.

- (extra credit?) simple chat program: this doesn't really fit the theme,
but it's an introduction to networking / sockets, which could be useful.
(and the intro class had lots of fun sending messages back and forth in
class.)

At this point, I'm hoping he'll be comfortable enough to begin working on a
more complete game (most likely, using pygame, as he hasn't expressed much
interest in 3D).  Some ideas for classic/simple/well-defined games to try:
- blob game (what is this one actually called? where the player absorbs
smaller entities to grow but dies if he runs into a bigger entity)
- tank battle (again, not sure on the name. two players, moving around,
shooting at each other on a map with obstructions)
- maze (bonus points for a maze generation algorithm)
- snake
- frogger
- asteroids
- etc.

This doesn't include a lot of standard but less flashy stuff e.g. advanced
data structures, graphs, sorting algorithms, because the idea was to find
projects that would be tra

Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread aseem bansal

Ok I'll mail by e-mail now. Hope that it reaches the place correctly.-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-18 Thread Albert van der Horst
In article ,
Chris Angelico   wrote:
>On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
> wrote:
>> I think that they're disappointed when I show them how much they have to
>understand just to write a program that plays Tic Tac Toe.
>
>
>The disillusionment of every novice programmer, I think. It starts out
>as "I want to learn programming and make a game". Real programming is
>more like "I can automate mundane tasks", which doesn't sound half as
>exciting. But this is why I'm dubious of programming courses that
>actually try to hold onto the "let's make a game" concept, because the
>students are likely to get a bit of a let-down on realizing that it
>really doesn't work that easily ("this is a two-week course, at the
>end of it I should have written the next 
>for all my friends").

Now comes the Forth experience.

I did the following experiment with a psychology student, who had
never been exposed to computers and had no prior experience. He
aquired a Jupiter Ace, which has Forth as a built in language. So his
only exposure was to Forth. Now I started to teach him programming,
using the cartoon book "starting Forth". Once in a weeek we sat
together and worked through some exercises.

After 6 weeks he surprised me. He had programmed the game pong
which is a simple table tennis like game, where you have to
keep a ball in play.
He never gave me a a chance to prevent him having a traumatic experience
of failure by telling him that was not a task a novice should start.
Or for that matter that such any real time programming requires considerable
up front planning and design.
[This was an adult, and at the time university students in the
Netherlands were certified intelligent and skilled and disciplined
in learning.]

The lesson that is in there for you is to not hold your students back.
They may surprise you!

Groetjes Albert






>
>ChrisA
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Grant Edwards
On 2013-07-18, Chris Angelico  wrote:
> On Thu, Jul 18, 2013 at 4:11 PM, Aseem Bansal  wrote:
>> @vikash agrawal
>>
>> About GUI I discussed it at 
>> https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I 
>> am thinking about using PySide 1.2 for clients of chat system. I think I'll 
>> need downloadable clients if I want to make something like google talk. Then 
>> I'll need to implement server side programming also. I think google app 
>> engine would be suitable for this as it is going to be always online.
>
> Hrm. Rather than pointing people to Google Groups, which a number here
> (and not unreasonably) detest, you may want to link to the python-list
> archive:
>
> http://mail.python.org/pipermail/python-list/2013-July/thread.html#651359

While that's the canonical archive, the UI is awful.  I find gmane's
web UI to be _far_ more friendly and useful than the pipermail archive
UI:

http://thread.gmane.org/gmane.comp.python.general/737271/

 1) The search facility sort-of works (though using google with
site:gmane.org:/gmane.comp.python usually works better).

 2) You can post from the gmane web UI.

 3) It offers both a threaded and a flat, blog-like version.

-- 
Grant Edwards   grant.b.edwardsYow! We just joined the
  at   civil hair patrol!
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Homework help requested (not what you think!)

2013-07-18 Thread Gene Heskett
On Thursday 18 July 2013 09:04:32 Albert van der Horst did opine:

> In article ,
> 
> Chris Angelico   wrote:
> >On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
> >
> > wrote:
> >> I think that they're disappointed when I show them how much they have
> >> to
> >
> >understand just to write a program that plays Tic Tac Toe.
> >
> >
> >The disillusionment of every novice programmer, I think. It starts out
> >as "I want to learn programming and make a game". Real programming is
> >more like "I can automate mundane tasks", which doesn't sound half as
> >exciting. But this is why I'm dubious of programming courses that
> >actually try to hold onto the "let's make a game" concept, because the
> >students are likely to get a bit of a let-down on realizing that it
> >really doesn't work that easily ("this is a two-week course, at the
> >end of it I should have written the next 
> >for all my friends").
> 
> Now comes the Forth experience.
> 
> I did the following experiment with a psychology student, who had
> never been exposed to computers and had no prior experience. He
> aquired a Jupiter Ace, which has Forth as a built in language. So his
> only exposure was to Forth. Now I started to teach him programming,
> using the cartoon book "starting Forth". Once in a weeek we sat
> together and worked through some exercises.
> 
> After 6 weeks he surprised me. He had programmed the game pong
> which is a simple table tennis like game, where you have to
> keep a ball in play.
> He never gave me a a chance to prevent him having a traumatic experience
> of failure by telling him that was not a task a novice should start.
> Or for that matter that such any real time programming requires
> considerable up front planning and design.
> [This was an adult, and at the time university students in the
> Netherlands were certified intelligent and skilled and disciplined
> in learning.]
> 
> The lesson that is in there for you is to not hold your students back.
> They may surprise you!
> 
> Groetjes Albert
> 
I'll 2nd those thoughts, and tell 2 or 3 stories.

When the Timex 1000 was new, I bought one for my kids and turned them loose 
with it.  Within a week my 10 year old had composed a car graphic, and 
written a small program to drive it around on the screen.

Back in a slightly newer time frame, Mr. Brodie's Forth, where you built 
your own extensions to the language, was used for a time at a small CA 
hospital as the hospitals accounting system, on a machine with only 64k of 
dram.  A TRS-80 Color Computer we now call the old grey ghost.

Fast forward 5 years from then, I wrote a program to work with a Grass 
Valley Group 300-3A/B television video switcher, which you could teach to 
do tricks, but it didn't have a means to save and reload them without 
buying a $20,000 EDISK accessory package.

So I wrote one in Basic09, running on a Color Computer 2, still only 64k of 
dram, based on a copy of the com protocol that had come with the switcher 
when we had purchased it used from KTLA-TV.  I wrote it on station time, 
and sold the station the hardware at about what it was worth at the time 
for a coco2 and 2 disk drives, $275.  14 years later as I was getting ready 
to retire and no one else knew that switcher, it was replaced, and my 'E-
DISK' was no longer needed, so they gave it to me, so I still have it in my 
'coco' collection in the basement.

Moral of course is never tell somebody it can't be done, he'll eat your 
lunch by doing it.  Oh, BTW, mine was 4x faster, and instead of a 2 hex 
digit display for file names, gave the tech directors English filenames on 
a small video screen.  They loved it because each one could then have his 
own personalized bag of video tricks to use during a news cast.

> >ChrisA


Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page:  is up!
My views 

Syntactic sugar causes cancer of the semicolon.
-- Epigrams in Programming, ACM SIGPLAN Sept. 1982
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why on CentOS, python consumes too much memory ?

2013-07-18 Thread Michael Torrie
On 07/18/2013 03:13 AM, William Bai wrote:
> I found that it was caused by not by python but by
> /usr/lib/locale/locale-archive, the same problem as that described
> in http://illiterat.livejournal.com/4615.html.

Too funny.  So in other words there isn't a problem at all.  What you
thought was RAM usage was really just a memory-mapped file.  That's why
Antoine said that using VSS to determine memory usage is not valid at
all in determining memory footprint.  VSS shows all kinds of things from
shared libraries to locale archives that have zero impact on RAM usage.
 Every app will show at least the size of glibc in its VSS number.

What is "too much memory" anyway?  What do you mean by "consume too much
memory?"  Now if your script has a resource leak and is long-running,
then that's a problem, but the solution is to fix your resource leak,
not have the OS kill your app when it exceeds the RLIMIT.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Homework help requested (not what you think!)

2013-07-18 Thread Joseph Clark
Not to open Pandora's box or anything, but are you aware of the Roguelike 
community (subculture?) (cult?) of game development?  Rogue was an old 
"text-based" role playing game for Unix, "text-based" in the sense that it used 
the console as a 2D map and ASCII characters as graphics.  There has been a 
sort of revival of the genre and a lot of amateur game developers have done 
some simple or complex variations on the theme.  They're not all RPGs.  The 
category is defined by a few commonalities like procedural content generation.

There are very active forums and an extensive wiki.  I think these might be 
particularly appropriate fodder for a tutoring experience because they are 
neatly broken down into bite-sized chunks.  One day you could do procedural map 
generation, another day AI, etc.  And all these lessons generalize to the 
"professional" game development world.

Look at this forum: http://forums.roguetemple.com/index.php?board=7.0
This wiki: http://roguebasin.roguelikedevelopment.org/index.php?title=Main_Page 
This Python tutorial: 
http://roguebasin.roguelikedevelopment.org/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod

By the way, I tried my hand at Markov chain name generation, too.  My python 
code is at 
https://github.com/joeclark77net/jc77rogue/blob/master/program/namegen.py
and what it does is read a corpus of names and generate new names that sound 
like that corpus.  So you feed it a list of Roman names and it will give you 
fake names that sound Roman.

// joseph w. clark , phd , visiting research associate
\\ university of nebraska at omaha - college of IS&T

> Date: Tue, 16 Jul 2013 15:43:45 -0700
> Subject: Homework help requested (not what you think!)
> From: [email protected]
> To: [email protected]
>
> Hi folks,
>
> No, I'm not asking for YOU to help ME with a Python homework assignment!
>
> Previously, I mentioned that I was starting to teach my son Python.
>
> https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ
>
> He just took a course at his high school called Web Technology and Design. 
> They had the students use tools like Dream Weaver, but they also hand-coded 
> some HTML and JavaScript. He has a little experience. I am building on it.
>
> Well, a few other parents caught wind of what I was doing with my son, and 
> they asked me whether I could tutor their kids, too. I accepted the jobs (for 
> pay, actually).
>
> The kids all claim to be interested. They all want to write the next great 3D 
> video game. Thus, I'm a little surprised that the kids don't actually try to 
> sit down and code without me prompting them. I think that they're 
> disappointed when I show them how much they have to understand just to write 
> a program that plays Tic Tac Toe.
>
> Where programming is concerned, I'm an autodidact. I started programming when 
> I was twelve, with little more guidance than the Applesoft Basic manual and 
> the occasional issue of Byte Magazine. I hacked away. Over the years, I have 
> acquired a working knowledge of BASIC, 6502 assembly language, Pascal, C, and 
> finally Python (my favorite). If I knew how to impart a love of 
> experimentation to my students, I would do that.
>
> One kid looks like he's ready to forge ahead. In the mean time, one parent 
> has recognized his son's lack of independence, and has asked me to assign 
> programming homework. I hope it doesn't kill the kid's enthusiasm, but I'm 
> willing to try it.
>
> So, what I am seeking are suggestions for programming assignments that I can 
> give to brand-new students of Python. Please keep in mind that none of them 
> are even up to the task of a simple algorithm like Bubble Sort -- at least, 
> not yet.
>
> Many thanks!
> --
> http://mail.python.org/mailman/listinfo/python-list   
>   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Terry Reedy

On 7/18/2013 3:29 AM, Aseem Bansal wrote:


About reading comp.lang.python can you suggest how to read it and
reply?


To read this list as a newsgroup use news.gmane.org. The difference 
between the mailing list interface and newsgroup interface is that the 
latter automatically segregates messages by group and only downloads the 
messages you want to read. Gmane is also a better way to search the archive.



I have never read a newsgroup leave alone participated in one.
I am used to forums like stackoverflow. Any way to read it and reply
by one interface? If not, give any suggestion. I'll use that.


I use Thunderbird. There is almost no difference between replying to 
emails and replying to newsgroup posts.


--
Terry Jan Reedy

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


Jabber Bot

2013-07-18 Thread Matt
Anyone have any luck with creating Jabber Bots?

Everyone I have found so far for python 3.3 has been outdated, or the required 
modules are outdated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Serhiy Storchaka

18.07.13 20:04, Terry Reedy написав(ла):

On 7/18/2013 3:29 AM, Aseem Bansal wrote:

About reading comp.lang.python can you suggest how to read it and
reply?


To read this list as a newsgroup use news.gmane.org. The difference
between the mailing list interface and newsgroup interface is that the
latter automatically segregates messages by group and only downloads the
messages you want to read. Gmane is also a better way to search the
archive.


Also newsgroup interface allow you reply to messages that have already 
been posted before your subscription.



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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Grant Edwards
On 2013-07-18, Serhiy Storchaka  wrote:
> 18.07.13 20:04, Terry Reedy ??():
>> On 7/18/2013 3:29 AM, Aseem Bansal wrote:
>>> About reading comp.lang.python can you suggest how to read it and
>>> reply?
>>
>> To read this list as a newsgroup use news.gmane.org. The difference
>> between the mailing list interface and newsgroup interface is that the
>> latter automatically segregates messages by group and only downloads the
>> messages you want to read. Gmane is also a better way to search the
>> archive.
>
> Also newsgroup interface allow you reply to messages that have already 
> been posted before your subscription.

Indeed.  I read about 20 mailing lists by pointing a newsreader (I use
slrn) at gmane.org.  I find it to take far less effort than actualling
having all of those messages actually sent to me.  For _some_ of the
gmane groups/lists you will actually have to subscribe to the mailing
list in question if you want to be allowed to post messages -- but in
your account settings for that mailing list server you can turn off
delivery, so that it doesn't actually send you any of the postings.

I really can't recommend gmane.org highly enough.

[I don't actually read the python list using gmane.org, since I've
read it from a Usenet news server via the group comp.lang.python since
long before I discovered gmane.org.]

-- 
Grant Edwards   grant.b.edwardsYow! Not SENSUOUS ... only
  at   "FROLICSOME" ... and in
  gmail.comneed of DENTAL WORK ... in
   PAIN!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python HTTP POST

2013-07-18 Thread Sivaram Neelakantan
On Thu, Jul 18 2013,Joel Goldstick wrote:


[snipped 28 lines]

>
> Many people find urllib and urllib2 to be confusing.  There is a module
> called requests which makes this stuff a lot easier.  ymmv
>
> http://docs.python-requests.org/en/latest/

Yes, please use this instead of the url* ones, easier to work with and
tinker.  I just finished writing a small scraper using it.  The
documentation too is very good.


 sivaram
 -- 

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


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Owen Marshall
On 2013-07-18, Grant Edwards  wrote:
> On 2013-07-18, Serhiy Storchaka  wrote:
>> 18.07.13 20:04, Terry Reedy ??():
>>> On 7/18/2013 3:29 AM, Aseem Bansal wrote:
 About reading comp.lang.python can you suggest how to read it and
 reply?
>>>
>>> To read this list as a newsgroup use news.gmane.org. The difference
>>> between the mailing list interface and newsgroup interface is that the
>>> latter automatically segregates messages by group and only downloads the
>>> messages you want to read. Gmane is also a better way to search the
>>> archive.
>>
>> Also newsgroup interface allow you reply to messages that have already
>> been posted before your subscription.
>
> Indeed.  I read about 20 mailing lists by pointing a newsreader (I use
> slrn) at gmane.org.  I find it to take far less effort than actualling
> having all of those messages actually sent to me.  For _some_ of the
> gmane groups/lists you will actually have to subscribe to the mailing
> list in question if you want to be allowed to post messages -- but in
> your account settings for that mailing list server you can turn off
> delivery, so that it doesn't actually send you any of the postings.
>
> I really can't recommend gmane.org highly enough.
>
> [I don't actually read the python list using gmane.org, since I've
> read it from a Usenet news server via the group comp.lang.python since
> long before I discovered gmane.org.]
>

Huh - I (foolishly) didn't realize gmane actually had NNTP, I've always
used it to search mailing lists. If the list dumped to usenet (much like
c.l.python) I'd post through sunsite.dk, which is a very nice usenet
provider. But that still meant several annoying mailing list
subscriptions.

... man, I'm really glad I read your post :-)

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


Re: RE Module Performance

2013-07-18 Thread 88888 Dihedral
Devyn Collier Johnson於 2013年7月16日星期二UTC+8下午6時30分33秒寫道:
> Am 07/12/2013 07:16 PM, schrieb MRAB:
> 
> > On 12/07/2013 23:16, Tim Delaney wrote:
> 
> >> On 13 July 2013 03:58, Devyn Collier Johnson  
> >> > wrote:
> 
> >>
> 
> >>
> 
> >> Thanks for the thorough response. I learned a lot. You should write
> 
> >> articles on Python.
> 
> >> I plan to spend some time optimizing the re.py module for Unix
> 
> >> systems. I would love to amp up my programs that use that module.
> 
> >>
> 
> >>
> 
> >> If you are finding that regular expressions are taking too much time,
> 
> >> have a look at the https://pypi.python.org/pypi/re2/ and
> 
> >> https://pypi.python.org/pypi/regex/2013-06-26 modules to see if they
> 
> >> already give you enough of a speedup.
> 
> >>
> 
> > FYI, you're better off going to http://pypi.python.org/pypi/regex
> 
> > because that will take you to the latest version.
> 
> Thank you everyone for the suggestions. I have not tried them yet.
> 
> 
> 
> Devyn Collier Johnson

I was thinking to decompose RE patterns into string matching 
formats of various strings in some formats.

Anyway that involves some compiler techniques.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jabber Bot

2013-07-18 Thread Fábio Santos
On 18 Jul 2013 18:52, "Matt"  wrote:
>
> Anyone have any luck with creating Jabber Bots?
>
> Everyone I have found so far for python 3.3 has been outdated, or the
required modules are outdated.

You can find some modules here.

http://stackoverflow.com/questions/1901828/best-python-xmpp-jabber-client-library

If none of these is up to date or good for your purposes, you could
manipulate XML using ElementTree.

As for AI, someone else may be able to help you (if dihedral said something
helpful that would be pretty meta) as I don't have any experience there.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] Elasticluster 1.0.1, a tool for cluster provisioning in the cloud

2013-07-18 Thread riccardo . murri
The Grid Computing Competence Center (GC3) is pleased to announce
release 1.0.1 of Elasticluster.

Elasticluster is a Python tool to automate the creation, configuration
and management of clusters of virtual machines hosted on a cloud.  It
can provision clusters on Amazon's Elastic Compute Cloud EC2 and
compatible ones, like OpenStack.

Elasticluster leverages the Ansible automation framework to deploy and
configure software on the virtual cluster.  Any Ansible playbook can
in principle be used with Elasticluster; the default distribution
contains recipes for:

* Hadoop clusters with HDFS
* HPC clusters based on SLURM, SGE, or PBS
* storage clusters running Ceph, GlusterFS or PVFS

A video demoes the basic features of Elasticluster setting up a SLURM
compute cluster: http://youtu.be/cR3C7XCSMmA

The code is available from PyPI and GitHub.  If you are interested,
please visit http://gc3-uzh-ch.github.io/elasticluster/ or get in
touch with us at [email protected].

Kind regards,
(for the Grid Computing Competence Center)
Riccardo Murri

--
Riccardo Murri
http://www.gc3.uzh.ch/people/rm

Grid Computing Competence Centre
University of Zurich
Winterthurerstrasse 190, CH-8057 Zürich (Switzerland)
Tel: +41 44 635 4222
Fax: +41 44 635 6888
-- 
http://mail.python.org/mailman/listinfo/python-list


Support for Mixed Mode Python/C++ debugging in Visual Studio

2013-07-18 Thread python tools


Hi folks,

1st time poster – apologies if I’m breaking any protocols…

We were told that this would be a good alias to announce this on:  a few Python 
& OSS enthusiasts and Microsoft have created a plug-in for Visual Studio that 
enables Python <-> C/C++ debugging.  You may find this useful for debugging 
your extension modules.


A quick video overview of the mixed mode debugging feature: 
http://www.youtube.com/watch?v=wvJaKQ94lBY&hd=1 (HD) 

Documentation: 
https://pytools.codeplex.com/wikipage?title=Mixed-mode%20debugging

Python Tools for Visual Studio is free (and OSS): http://pytools.codeplex.com 

Cheers,

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 5:12:08 AM UTC-4, Joshua Landau wrote:
> On 18 July 2013 00:58, CTSB01  wrote:
> 
> > Please let me know if this is unclear.  I will certainly continue revising 
> > until it makes sense to those reading.
> 
> 
> 
> Can you summarize what your question is? Leave aside the details of
> 
> the function, just explain what thing in particular you aren't able
> 
> to do.

Hi Joshua,

I actually managed to find a certain block like this:

 def phi_m(x, m):
...   rtn = []
...   for n2 in range(0, len(x) * m - 2:
... n = n2 / m
... r = n2 - n * m
... rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
... print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
...   rtn 

However, I am getting the error "expected an indented block" on line two.  Any 
idea why?  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Gary Herron

On 07/18/2013 02:57 PM, CTSB01 wrote:

On Thursday, July 18, 2013 5:12:08 AM UTC-4, Joshua Landau wrote:

On 18 July 2013 00:58, CTSB01  wrote:


Please let me know if this is unclear.  I will certainly continue revising 
until it makes sense to those reading.



Can you summarize what your question is? Leave aside the details of

the function, just explain what thing in particular you aren't able

to do.

Hi Joshua,

I actually managed to find a certain block like this:

  def phi_m(x, m):
...   rtn = []
...   for n2 in range(0, len(x) * m - 2:

That 'for' line has miss-matched parentheses.

... n = n2 / m
... r = n2 - n * m
... rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
... print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
...   rtn

However, I am getting the error "expected an indented block" on line two.  Any 
idea why?



--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 6:12:52 PM UTC-4, Gary Herron wrote:
> On 07/18/2013 02:57 PM, CTSB01 wrote:
> 
> > On Thursday, July 18, 2013 5:12:08 AM UTC-4, Joshua Landau wrote:
> 
> >> On 18 July 2013 00:58, CTSB01  wrote:
> 
> >>
> 
> >>> Please let me know if this is unclear.  I will certainly continue 
> >>> revising until it makes sense to those reading.
> 
> >>
> 
> >>
> 
> >> Can you summarize what your question is? Leave aside the details of
> 
> >>
> 
> >> the function, just explain what thing in particular you aren't able
> 
> >>
> 
> >> to do.
> 
> > Hi Joshua,
> 
> >
> 
> > I actually managed to find a certain block like this:
> 
> >
> 
> >   def phi_m(x, m):
> 
> > ...   rtn = []
> 
> > ...   for n2 in range(0, len(x) * m - 2:
> 
> That 'for' line has miss-matched parentheses.
> 
> > ... n = n2 / m
> 
> > ... r = n2 - n * m
> 
> > ... rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> > ... print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
> 
> > ...   rtn
> 
> >
> 
> > However, I am getting the error "expected an indented block" on line two.  
> > Any idea why?
> 
> 
> 
> 
> 
> -- 
> 
> Dr. Gary Herron
> 
> Department of Computer Science
> 
> DigiPen Institute of Technology
> 
> (425) 895-4418

Hi Gary,

I fixed that issue, but I still end up with the same error.  Specifically:

  
  File "", line 2
...   rtn = []
^
IndentationError: expected an indented block
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Michael Torrie
On 07/17/2013 11:39 PM, Eric S. Johansson wrote:
> Not discourage you but this is a "been there, done that" kind of project.  
> You could learn more from reading somebody else is code. What hasn't been  
> done, and this would be very cool, is a chat program that works  
> peer-to-peer with no central server. To do this, you would probably need  
> to know about distributed hash tables and methods of piercing address  
> translation firewalls (think UDP).

University CS curricula across the world would disagree with your
assessment of the usefulness of "been there, done that."  Indeed that's
how you learn by doing simple things that have been done many times
before, and discovering the magic of programming and software design.
My uni's CS undergrad degree consists of dozens of contrived projects
that have been done before.  Web crawlers, compilers, expert systems,
chat systems, word counters, etc.

And that's the same way with all fields of endeavor.  Indeed it'd be
silly to tell an enthused hobby builder that building a shed is
pointless as it's been done before.  The shed itself, which would
arguably be useful, is beside the point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Michael Torrie
On 07/18/2013 12:19 PM, Owen Marshall wrote:
> Huh - I (foolishly) didn't realize gmane actually had NNTP, I've always
> used it to search mailing lists. If the list dumped to usenet (much like
> c.l.python) I'd post through sunsite.dk, which is a very nice usenet
> provider. But that still meant several annoying mailing list
> subscriptions.
> 
> ... man, I'm really glad I read your post :-)

I'm a bit confused.  This list *is* c.l.python (I happen to read via
e-mail through the mailing list).  So you can reach it from sunsite.dk
can you not?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Jul 18, 2013 4:23 PM, "CTSB01"  wrote:
>
>   File "", line 2
> ...   rtn = []
> ^

The "..." is the continuation prompt from the interactive interpreter, not
part of the code. Don't paste it into Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 6:49:03 PM UTC-4, Ian wrote:
> On Jul 18, 2013 4:23 PM, "CTSB01"  wrote:
> 
> >
> 
> >   File "", line 2
> 
> >     ...   rtn = []
> 
> >     ^
> 
> The "..." is the continuation prompt from the interactive interpreter, not 
> part of the code. Don't paste it into Python.

Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid syntax' 
issue unfortunately.

>> def phi_m(x,m):
  rtn = []
  for n2 in range(0, len(x)*m - 2):
n = n2 / m
r = n2 - n * m
rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
  rtn

on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is it 
something obvious?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Thu, Jul 18, 2013 at 5:04 PM, CTSB01  wrote:
> Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid 
> syntax' issue unfortunately.
>
>>> def phi_m(x,m):
>   rtn = []
>   for n2 in range(0, len(x)*m - 2):
> n = n2 / m
> r = n2 - n * m
> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
>   rtn
>
> on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is it 
> something obvious?

Are you using Python 2 or 3?  "print" has changed from a statement to
a function, so the above syntax would be invalid in Python 3.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Ian Kelly
On Thu, Jul 18, 2013 at 5:42 PM, Ian Kelly  wrote:
> On Thu, Jul 18, 2013 at 5:04 PM, CTSB01  wrote:
>> Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid 
>> syntax' issue unfortunately.
>>
 def phi_m(x,m):
>>   rtn = []
>>   for n2 in range(0, len(x)*m - 2):
>> n = n2 / m
>> r = n2 - n * m
>> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
>> print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
>>   rtn
>>
>> on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is it 
>> something obvious?
>
> Are you using Python 2 or 3?  "print" has changed from a statement to
> a function, so the above syntax would be invalid in Python 3.

Note also that in Python 3 you should change the line "n = n2 / m" to
"n = n2 // m" because the syntax for integer division has also
changed.

And regardless of your Python version, the last line should probably
be "return rtn", not just "rtn".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Rhodri James
On Fri, 19 Jul 2013 00:04:33 +0100, CTSB01   
wrote:



On Thursday, July 18, 2013 6:49:03 PM UTC-4, Ian wrote:

On Jul 18, 2013 4:23 PM, "CTSB01"  wrote:

>

>   File "", line 2

> ...   rtn = []

> ^

The "..." is the continuation prompt from the interactive interpreter,  
not part of the code. Don't paste it into Python.


Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid  
syntax' issue unfortunately.



def phi_m(x,m):

  rtn = []
  for n2 in range(0, len(x)*m - 2):
n = n2 / m
r = n2 - n * m
rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
  rtn

on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is  
it something obvious?


Are you using Python 2.x or 3.x?  That print statement is valid 2.x, but  
"print" is a function in Python 3, so the parameter need parentheses  
around them.


This would all involve a lot less guesswork if you cut and pasted both  
your code and the error traceback.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Dave Angel

On 07/18/2013 07:04 PM, CTSB01 wrote:

On Thursday, July 18, 2013 6:49:03 PM UTC-4, Ian wrote:

On Jul 18, 2013 4:23 PM, "CTSB01"  wrote:






   File "", line 2



 ...   rtn = []



 ^


The "..." is the continuation prompt from the interactive interpreter, not part 
of the code. Don't paste it into Python.


Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid syntax' 
issue unfortunately.


def phi_m(x,m):

   rtn = []
   for n2 in range(0, len(x)*m - 2):
 n = n2 / m
 r = n2 - n * m
 rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
 print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
   rtn

on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is it 
something obvious?



It's only obvious if you're using Python 3.x.  You have forgotten the 
parentheses in the call to the print() function.


On the other hand, if this is Python 2.x, I have no idea.  Next time, 
please paste the actual error, not paraphrased.  The error message 
includes a traceback. and a pointer to where in the line the error was 
detected.  If it's pointing at the end of the second token, you must be 
running Python 3.x


And since you're using that annoying googlegroups, see this:

http://wiki.python.org/moin/GoogleGroupsPython




--
DaveA

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 7:45:49 PM UTC-4, Ian wrote:
> On Thu, Jul 18, 2013 at 5:42 PM, Ian Kelly  wrote:
> 
> > On Thu, Jul 18, 2013 at 5:04 PM, CTSB01  wrote:
> 
> >> Thanks Ian.  That worked regarding that issue.  Now I have an 'invalid 
> >> syntax' issue unfortunately.
> 
> >>
> 
>  def phi_m(x,m):
> 
> >>   rtn = []
> 
> >>   for n2 in range(0, len(x)*m - 2):
> 
> >> n = n2 / m
> 
> >> r = n2 - n * m
> 
> >> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> >> print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
> 
> >>   rtn
> 
> >>
> 
> >> on the line  print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn  Is 
> >> it something obvious?
> 
> >
> 
> > Are you using Python 2 or 3?  "print" has changed from a statement to
> 
> > a function, so the above syntax would be invalid in Python 3.
> 
> 
> 
> Note also that in Python 3 you should change the line "n = n2 / m" to
> 
> "n = n2 // m" because the syntax for integer division has also
> 
> changed.
> 
> 
> 
> And regardless of your Python version, the last line should probably
> 
> be "return rtn", not just "rtn".

Thanks!  I'm using 3.3.2.  As I'm new to this, do you think it's a better idea 
to jump to 3.3.2 or stick with 2.7?  I, for all intents and purposes, know 
neither.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
 > It's only obvious if you're using Python 3.x.  You have forgotten the 
> 
> parentheses in the call to the print() function.
> 
> 
> On the other hand, if this is Python 2.x, I have no idea.  Next time, 
> 
> please paste the actual error, not paraphrased.  The error message 
> 
> includes a traceback. and a pointer to where in the line the error was 
> 
> detected.  If it's pointing at the end of the second token, you must be 
> 
> running Python 3.x
> And since you're using that annoying googlegroups, see this:
>
> http://wiki.python.org/moin/GoogleGroupsPython
> 
> 
> -- 
> 
> DaveA

Hi Dave,

There aren't any emails in the Cc slot so I imagine that part is fine, I will 
definitely edit the extra quotes though I made the mistake of thinking it was 
just google being google.  For reference , I'm running Python 3.x.  I'll try 
out putting the quotes around it.   The full code is:

>>> def phi_m(x,m):
  rtn = []
  for n2 in range(0, len(x)*m - 2):
n = n2 / m
r = n2 - n * m
rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
  rtn
  
SyntaxError: invalid syntax

where the second apostrophe in 'n2 =' is marked in orange.  Thanks to everyone 
who's helped out so far, hopefully with some experience I'll be able sort out 
any syntax issues that come my way.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)

2013-07-18 Thread Owen Marshall
On 2013-07-18, Michael Torrie  wrote:
> On 07/18/2013 12:19 PM, Owen Marshall wrote:
>> Huh - I (foolishly) didn't realize gmane actually had NNTP, I've always
>> used it to search mailing lists. If the list dumped to usenet (much like
>> c.l.python) I'd post through sunsite.dk, which is a very nice usenet
>> provider. But that still meant several annoying mailing list
>> subscriptions.
>>
>> ... man, I'm really glad I read your post :-)
>
> I'm a bit confused.  This list *is* c.l.python (I happen to read via
> e-mail through the mailing list).  So you can reach it from sunsite.dk
> can you not?

Doesn't surprise me, I was confusing ;-)

What I was saying was that my workflow used to be this:

For maliing lists that dump to a newsgroup (c.l.python) I'd post to the
group via usenet (sunsite.dk)

For mailing lists that _do not_ have a direct newsgroup gateway (flask,
etc.) I'd have to subscribe and read them in my mail client.


So I used to think gmane was just a way of reading a bunch of mailing
lists. *But now* I know it is much more - it's an NNTP <==> mail gateway
that also has a web viewer.

Now I can point my slrn to news.gmane.net and see the flask mailing
list, ruby-talk, ... -- which I much prefer to using email.


Again, perfectly obvious stuff had I actually _read_ the gmane FAQ. But
who has time for that ;-)

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Dave Angel

On 07/18/2013 08:35 PM, CTSB01 wrote:

  > It's only obvious if you're using Python 3.x.  You have forgotten the


parentheses in the call to the print() function.


On the other hand, if this is Python 2.x, I have no idea.  Next time,

please paste the actual error, not paraphrased.  The error message

includes a traceback. and a pointer to where in the line the error was

detected.  If it's pointing at the end of the second token, you must be

running Python 3.x
And since you're using that annoying googlegroups, see this:

http://wiki.python.org/moin/GoogleGroupsPython


--

DaveA


Hi Dave,

There aren't any emails in the Cc slot so I imagine that part is fine, I will 
definitely edit the extra quotes though I made the mistake of thinking it was 
just google being google.


Exactly.  And remember, the list is comp.lang.python, while googlegroups 
has tried to pre-empt it by bridging.  Most of us get to it either 
through the nntp server at gmane.org or via email subscription at 
[email protected]




 For reference , I'm running Python 3.x.

>  I'll try out putting the quotes around it.

Parentheses, not quotes.  print() is a function in 3.x


  The full code is:


def phi_m(x,m):

   rtn = []
   for n2 in range(0, len(x)*m - 2):
 n = n2 / m
 r = n2 - n * m
 rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
 print 'n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn
   rtn

SyntaxError: invalid syntax

where the second apostrophe in 'n2 =' is marked in orange.  Thanks to everyone 
who's helped out so far, hopefully with some experience I'll be able sort out 
any syntax issues that come my way.

Don't paraphrase.  Just copy/paste it into your email message.  And I'm 
assuming you know to run things from the terminal window, and not from 
IDLE or something else that messes up the error messages.  Your comment 
about 'orange' doesn't sound promising.


As Ian pointed out, you have no return value in this function.  You 
calculate something called 'rtn', but never use it.  The last line 
accomplishes nothing, since rtn is neither assigned nor returned, nor 
passed nor...   You probably wanted:


  return  rtn





--
DaveA

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
Thanks for the alternative links, I'll use gmane.org as an access point next 
time.

> 
> Don't paraphrase.  Just copy/paste it into your email message.  And I'm 
> 
> assuming you know to run things from the terminal window, and not from 
> 
> IDLE or something else that messes up the error messages.  Your comment 
> 
> about 'orange' doesn't sound promising.
> 
> 
> 
> As Ian pointed out, you have no return value in this function.  You 
> 
> calculate something called 'rtn', but never use it.  The last line 
> 
> accomplishes nothing, since rtn is neither assigned nor returned, nor 
> 
> passed nor...   You probably wanted:
> 
> 
> 
>return  rtn
>

Does something like 

def phi_m(x, m):
  rtn = []
  for n2 in range(0, len(x) * m - 2):
n = n2 / m
r = n2 - n * m
rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
  return rtn

look right?

It doesn't seem to have any errors.  However, I do receive the following error 
when trying to implement an x after having defined phi:

>>> x = [0, 1, 1, 2, 3]
>>> phi_m(x, 2)
Traceback (most recent call last):
  File "", line 1, in 
phi_m(x, 2)
  File "", line 6, in phi_m
rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
TypeError: list indices must be integers, not float
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Dave Angel

On 07/18/2013 10:16 PM, CTSB01 wrote:






Does something like

def phi_m(x, m):
   rtn = []
   for n2 in range(0, len(x) * m - 2):
 n = n2 / m
 r = n2 - n * m
 rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
 print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
   return rtn

look right?


No, as Ian has pointed out, you need to use the // operator in Python 3 
if you want to get integer results.  So it'd be n = n2 // m


However, even better is to use the divmod() function, which  is intended 
for the purpose:


n, r = divmod(n2, m)



It doesn't seem to have any errors.  However, I do receive the following error 
when trying to implement an x after having defined phi:


x = [0, 1, 1, 2, 3]
phi_m(x, 2)

Traceback (most recent call last):
   File "", line 1, in 
 phi_m(x, 2)
   File "", line 6, in phi_m
 rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
TypeError: list indices must be integers, not float



That will be fixed if you correct the code as I described, so you'll get 
integers.


There is a Brezenham algorith that might accomplish this whole function 
more accurately, or more efficiently.  But I'd have to re-derive it, as 
it's been about 30 years since I used it.  And chances are that the 
efficiencies it brought to machine code won't matter much here.





--
DaveA

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


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread Fábio Santos
On 19 Jul 2013 03:24, "CTSB01"  wrote:
>
> Thanks for the alternative links, I'll use gmane.org as an access point
next time.
>
> >
> > Don't paraphrase.  Just copy/paste it into your email message.  And I'm
> >
> > assuming you know to run things from the terminal window, and not from
> >
> > IDLE or something else that messes up the error messages.  Your comment
> >
> > about 'orange' doesn't sound promising.
> >
> >
> >
> > As Ian pointed out, you have no return value in this function.  You
> >
> > calculate something called 'rtn', but never use it.  The last line
> >
> > accomplishes nothing, since rtn is neither assigned nor returned, nor
> >
> > passed nor...   You probably wanted:
> >
> >
> >
> >return  rtn
> >
>
> Does something like
>
> def phi_m(x, m):
>   rtn = []
>   for n2 in range(0, len(x) * m - 2):
> n = n2 / m
> r = n2 - n * m
> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
>   return rtn
>
> look right?
>
> It doesn't seem to have any errors.  However, I do receive the following
error when trying to implement an x after having defined phi:
>
> >>> x = [0, 1, 1, 2, 3]
> >>> phi_m(x, 2)
> Traceback (most recent call last):
>   File "", line 1, in 
> phi_m(x, 2)
>   File "", line 6, in phi_m
> rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> TypeError: list indices must be integers, not float

When you think about it, it makes sense. If you have a list, say,

[2, 5, 1]

You can say, I want the first item (0) or the third item(2) but never, the
one-and-a-halfeth (0.5) item. Python only accepts integer values when
accessing list items.

To access list items, convert your index into an integer value.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 10:48:23 PM UTC-4, Fábio Santos wrote:
> On 19 Jul 2013 03:24, "CTSB01"  wrote:
> 
> >
> 
> > Thanks for the alternative links, I'll use gmane.org as an access point 
> > next time.
> 
> >
> 
> > >
> 
> > > Don't paraphrase.  Just copy/paste it into your email message.  And I'm
> 
> > >
> 
> > > assuming you know to run things from the terminal window, and not from
> 
> > >
> 
> > > IDLE or something else that messes up the error messages.  Your comment
> 
> > >
> 
> > > about 'orange' doesn't sound promising.
> 
> > >
> 
> > >
> 
> > >
> 
> > > As Ian pointed out, you have no return value in this function.  You
> 
> > >
> 
> > > calculate something called 'rtn', but never use it.  The last line
> 
> > >
> 
> > > accomplishes nothing, since rtn is neither assigned nor returned, nor
> 
> > >
> 
> > > passed nor...   You probably wanted:
> 
> > >
> 
> > >
> 
> > >
> 
> > >        return  rtn
> 
> > >
> 
> >
> 
> > Does something like
> 
> >
> 
> > def phi_m(x, m):
> 
> >           rtn = []
> 
> >           for n2 in range(0, len(x) * m - 2):
> 
> >             n = n2 / m
> 
> >             r = n2 - n * m
> 
> >             rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> >             print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
> 
> >           return rtn
> 
> >
> 
> > look right?
> 
> >
> 
> > It doesn't seem to have any errors.  However, I do receive the following 
> > error when trying to implement an x after having defined phi:
> 
> >
> 
> > >>> x = [0, 1, 1, 2, 3]
> 
> > >>> phi_m(x, 2)
> 
> > Traceback (most recent call last):
> 
> >   File "", line 1, in 
> 
> >     phi_m(x, 2)
> 
> >   File "", line 6, in phi_m
> 
> >     rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> > TypeError: list indices must be integers, not float
> 
> When you think about it, it makes sense. If you have a list, say,
> 
> [2, 5, 1]
> 
> You can say, I want the first item (0) or the third item(2) but never, the 
> one-and-a-halfeth (0.5) item. Python only accepts integer values when 
> accessing list items.
> 
> To access list items, convert your index into an integer value.

Thanks Fabio.  Is there a statement that lets me specify that I only need it to 
take the integer values?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating a Program to Decompose a Number and Run a Function on that Decomposition

2013-07-18 Thread CTSB01
On Thursday, July 18, 2013 10:43:11 PM UTC-4, Dave Angel wrote:
> On 07/18/2013 10:16 PM, CTSB01 wrote:

> > Does something like
> 
> >
> 
> > def phi_m(x, m):
> 
> >rtn = []
> 
> >for n2 in range(0, len(x) * m - 2):
> 
> >  n = n2 / m
> 
> >  r = n2 - n * m
> 
> >  rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> >  print ('n2 =', n2, ': n =', n, ' r =' , r, ' rtn =', rtn)
> 
> >return rtn
> > look right?
> 
> No, as Ian has pointed out, you need to use the // operator in Python 3 
> 
> if you want to get integer results.  So it'd be n = n2 // m
> 
> However, even better is to use the divmod() function, which  is intended 
> 
> for the purpose:
> 
> 
> 
>  n, r = divmod(n2, m)
> 
> > It doesn't seem to have any errors.  However, I do receive the following 
> > error when trying to implement an x after having defined phi:
> 
>  x = [0, 1, 1, 2, 3]
> 
>  phi_m(x, 2)
> 
> > Traceback (most recent call last):
> 
> >File "", line 1, in 
> 
> >  phi_m(x, 2)
> 
> >File "", line 6, in phi_m
> 
> >  rtn.append(m * x[n] + r * (x[n + 1] - x[n]))
> 
> > TypeError: list indices must be integers, not float
> 
> 
> That will be fixed if you correct the code as I described, so you'll get 
> 
> integers.
> 
> There is a Brezenham algorith that might accomplish this whole function 
> 
> more accurately, or more efficiently.  But I'd have to re-derive it, as 
> 
> it's been about 30 years since I used it.  And chances are that the 
> 
> efficiencies it brought to machine code won't matter much here.
> 
> -- 
> 
> DaveA

Thanks Dave, I'll take a look at that.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: rom 0.16 - Redis object mapper for Python

2013-07-18 Thread Josiah Carlson
Hey everyone,

As time progresses, so does my Redis object mapper.

The "rom" package is a Redis object mapper for Python. It sports an
interface similar to Django's ORM, SQLAlchemy + Elixir, or Appengine's
datastore.

The changelog for recent releases can be seen below my signature.

You can find the package at:
https://www.github.com/josiahcarlson/rom
https://pypi.python.org/pypi/rom

Please CC me on any replies if you have any questions or comments.

Thank you,
 - Josiah

#--- 0.16

[added] Thanks to a feature request from https://github.com/jrsmith ,
Boolean
column support is now available.
[added] DateTime, Date, and Time column types because I was already adding
Boolean columns.
#--- 0.15

[fixed] Thanks to https://github.com/MickeyKim who fixed Json columns so
that
they round-trip after multiple saves.
#--- 0.14

[fixed] Thanks to https://github.com/mayfield the manifest is fixed for the
source installation.
#--- 0.13

[fixed] updating a model will no longer unindex the model on attributes that
weren't updated. Thanks to https://github.com/mayfield for the bug
report,
analysis, and initial pull request that ultimately resulted in the fix.
[fixed] pip requires, versioning, etc., thanks to fixes from
https://github.com/mayfield
[changed] Model.get_by() will now work on any type of indexed columns.
Unique
columns work as before, and other columns get pass-through to the
Model.query interface.
[changed] Model.get_by() and Model.query.filter() will both accept single
numbers as the value to match on (you don't need to specify a range if
you
are querying by equality).
[changed] all changes will be documented in this changelog.txt file to keep
a
list of everything that is going on with the project.
-- 
http://mail.python.org/mailman/listinfo/python-list