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 2:36 PM, Aseem Bansal asmbans...@gmail.com wrote:
 I wanted to do a little project for learning Python. I thought a chat system 
 will be good as it isn't something that I have ever done.

A good thing to start with. Yes, it's been done before, many times...
but if you think about it, it's the fundamental on which pretty much
everything else is derived. The step from a multi-person chat system
to a multiplayer game is very slight.

 I wanted to know what will I need? I think that would require me these
 1 learn network/socket programming
 2 find a free server to host my chat server
 3 GUI development for clients

Learn network programming, definitely. As an adjunct to that, learn
networking security. For instance, do not think in terms of the
client will only ever send X; the server has to be able to cope,
safely, with any stream of bytes coming from the socket. Also, be sure
you understand the difference between bytes (or octets) and Unicode
characters, and know what everything is. Python 3 helps with this.

Finding hosting (I'll use the word server here to mean the program,
and will say hosting when I mean a computer) is optional though; for
your first tests, use your own computer. You can run the server and a
number of clients all on the same computer, and alt-tab between them;
or, if you have a LAN, you can use that. Then when you want to expand
to the full internet and let your friends in on this, you can still
host it on your home internet connection, though you may need to
choose carefully which port you use (some home connections prevent
incoming port 25 and 80 traffic). You won't need to worry about
hosting until (a) you need it to be up 24x7 and don't want to depend
on your home system, and/or (b) you need more bandwidth/processing
than your home connection will do. Neither will be true of your first
experiments.

GUI development, in my opinion, should be left for Phase Two. Start by
making a very simple system that just works with plain text; later on,
make a fancy graphical interface. Keep the text version working, and
keep them compatible. Trust me, you'll appreciate that text one when
you start debugging - it'll be so easy to see what's going on.

 -I wanted to know whether these are all that I would need or are there more 
 things?
 -Will I need to learn a web framework like Django?

Hmm. I would think not; I'd recommend that a chat system work with TCP
sockets directly, for simplicity and performance. Working with a web
framework implies working with HTTP, and unless you're running this in
a web browser, there's no reason to do that.

 -Will I need to learn something for database management like sql for handling 
 people's account names and password?

Optional. Leave that for Phase Two; to start off with, just let people
type in their own names, and don't worry about authentication
initially (this isn't such a crazy idea - IRC largely works this way).
You can add authentication later.

 Any other advice for me(a novice programmer)?

Get to know as many tools as you can, so that when you're faced with a
problem, you can select the right one for the job. You are not Jeremy
Clarkson, your toolchest is not all hammers :)

In this particular instance, you may find that Python is the best
language for the clients, but not for the server. I've written a
number of chat-server-like systems, most notably MUD clients and
derivatives, and I use Pike for the server. Its biggest advantage
(over Python) is that you can tweak the code while it's running; I've
had Pike servers running for over two years on commodity hardware (and
would still have that uptime today if the UPS hadn't died). Still
trying to claw all that back.. up to 25 weeks so far. Pike and Python
are extremely similar in semantics (even down to having a
nearly-identical internal string representation, as of Python 3.3),
but have distinctly different syntax (Pike looks like C), and their
optimizations are quite different, so performance varies somewhat.
They're both high level languages that let you manipulate functions,
dictionaries, etc, as first-class objects, they're both sufficiently
high performance/efficiency to run something like this on 0.00 load
average (my server's load is more usually from Apache serving PHP
pages than it is from either Pike or Python), and both will serve you
well in this project.

One more tip: Don't be afraid to ask for help! I personally *love*
networking, and will gladly help out with any little problems you run
into; the same, I am sure, will be true of a good number of people on
this list. Networking is a complicated world, and there are a lot of
odd concepts to master; but it's also an immensely fun bunch of
technologies. Why play with just one computer when you can play with
half a dozen!

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
@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.

In the above scenario I wanted to know whether the database can be stored on 
google app engine itself? Is it possible? Having a chat system with server 
online and DB offline isn't going to be good. Should I consider heroku for this 
or can it be done using google app engine? Is it viable to have the DB on 
google appengine itself?

About using web frameworks, in the above scenario when there isn't an online 
website for chat would I need web frameworks? I am confused about this. Can 
server side programming be done in Python or by using a web framework only?
-- 
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 4:11 PM, Aseem Bansal asmbans...@gmail.com 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

 About using web frameworks, in the above scenario when there isn't an online 
 website for chat would I need web frameworks? I am confused about this. Can 
 server side programming be done in Python or by using a web framework only?

You can certainly do your server-side programming directly in Python;
in fact, I recommend it for this task. There's no reason to use HTTP,
much less a web framework (which usually consists of a structured way
to build HTML pages, plus a bunch of routing and stuff, none of which
you need). All you need is a simple structure for separating one
message from another. I would recommend either going MUD/TELNET style
and ending each message with a newline, or prefixing each message with
its length in octets. Both ways work very nicely; newline-termination
allows you to use a MUD client for debugging, which I find very
convenient (full disclosure: I am the author of multiple MUD clients,
including one that's zero-dollar and another that's free).

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
@Chris Angelico

Thanks. That cleared many doubts and your suggestions would definitely be 
useful. 

I am asking the next paragraph because you said about Python 3 helping with 
things. I am not looking for a debate or anything just a opinion. 

I learnt Python myself and everyone told me that Python 2 is status quo so I 
learned Python 2 and have been working with it. I am just 1.5 months in Python 
programming so should I consider switching to Python 3 if it helps with new 
things or should I stick with Python 2 to get a taste of what is currently out 
there?

About Pike, thanks for the heads up. But for now I'll use Python. I wanted to 
learn Python through this project. I'll leave Pike for later. Maybe Phase 1.5.

Aren't you guys posting in google groups? I thought you were because I can see 
your posts here. How do I post in python mailing list and see its archives 
instead of posting on google groups?
-- 
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 Andrew Berg
On 2013.07.18 01:36, Aseem Bansal wrote:
 I learnt Python myself and everyone told me that Python 2 is status quo so I 
 learned Python 2 and have been working with it. I am just 1.5 months in 
 Python programming so should I consider switching to Python 3 if it helps 
 with new things or should I stick with Python 2 to get a taste of what is 
 currently out there?
Python 2 is what some people are stuck with because their projects depend on 
huge libraries that have not yet made all their code compatible
with Python 3 (or on libraries that are not actively maintained or are being 
replaced by something else). All new code and new Python users
should be using Python 3 unless there is a pressing need for a library that 
requires Python 2.
Most popular libraries at this point have either been made compatible or have 
been replaced by something that supports Python 3. Python 3 is
no longer the shiny new thing to look at in the future - 3.0 was released in 
December 2008.

-- 
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
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 4:36 PM, Aseem Bansal asmbans...@gmail.com wrote:
 @Chris Angelico

 Thanks. That cleared many doubts and your suggestions would definitely be 
 useful.

 I am asking the next paragraph because you said about Python 3 helping with 
 things. I am not looking for a debate or anything just a opinion.

 I learnt Python myself and everyone told me that Python 2 is status quo so I 
 learned Python 2 and have been working with it. I am just 1.5 months in 
 Python programming so should I consider switching to Python 3 if it helps 
 with new things or should I stick with Python 2 to get a taste of what is 
 currently out there?

Python 3 is now the current Python. There'll be no more development on
Python 2 (bugfixes/security only, and even that won't be forever), so
I strongly recommend going to Python 3. You're writing new code, so
there's really no reason to use Python 2. All the core libraries
you'll be needing (socket, mainly) are available for Py3, and as I
mentioned earlier, Unicode handling is far superior (especially as of
3.3).

 About Pike, thanks for the heads up. But for now I'll use Python. I wanted to 
 learn Python through this project. I'll leave Pike for later. Maybe Phase 1.5.

Yep. My main point there is: Don't be too stuck on any one tool, learn
'em all. Learn Python now, you may find that you want to use Pike
later. Build your system so you can switch one thing out for another.

 Aren't you guys posting in google groups? I thought you were because I can 
 see your posts here. How do I post in python mailing list and see its 
 archives instead of posting on google groups?

Google Groups is one way (and one of the worse ways) of accessing
comp.lang.python, which is cross-mirrored with the mailing list
python-list@python.org - the easiest way is to simply subscribe to
either the newsgroup or the mailing list, using a newsreader or mail
client. As you see, I'm posting from gmail; there are a couple of
issues with using gmail here (it doesn't have a Reply List option,
for instance), but it's orders of magnitude less annoying than Google
Groups.

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
@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 asmbans...@gmail.com 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 fronag...@gmail.com:

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 asmbans...@gmail.com 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 python-list@python.org) 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 asmbans...@gmail.com 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 python-list@python.org? Or do I need to use pytho...@python.org 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 asmbans...@gmail.com wrote:
 I tried replying to your message by mail. I used the reply button and send it 
 to python-list@python.org? Or do I need to use pytho...@python.org 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 joshua at 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!
off to buy wine

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 scott.moore...@gmail.com 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 fronag...@gmail.com:
  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/pid/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
snowingbear at 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 john_lada...@sbcglobal.netwrote:

 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 tractable for 

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 mailman.4786.1374021635.3114.python-l...@python.org,
Chris Angelico  ros...@gmail.com wrote:
On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
john_lada...@sbcglobal.net 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 insert name of popular game
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@spearc.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 ros...@gmail.com wrote:
 On Thu, Jul 18, 2013 at 4:11 PM, Aseem Bansal asmbans...@gmail.com 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 mailman.4786.1374021635.3114.python-l...@python.org,
 
 Chris Angelico  ros...@gmail.com wrote:
 On Wed, Jul 17, 2013 at 8:43 AM, John Ladasky
 
 john_lada...@sbcglobal.net 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 insert name of popular game
 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: http://coyoteden.dyndns-free.com:85/gene is up!
My views 
http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml
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 IST

 Date: Tue, 16 Jul 2013 15:43:45 -0700
 Subject: Homework help requested (not what you think!)
 From: john_lada...@sbcglobal.net
 To: python-list@python.org

 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 storch...@gmail.com 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 invalid@invalid.invalid wrote:
 On 2013-07-18, Serhiy Storchaka storch...@gmail.com 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 devyncjohn...@gmail.com
 
  mailto:devyncjohn...@gmail.com 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 mattgrav...@gmail.com 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 elasticlus...@googlegroups.com.

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=wvJaKQ94lBYhd=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 scott.moore...@gmail.com 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 scott.moore...@gmail.com 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 scott.moore...@gmail.com 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 pyshell#9, 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 scott.moore...@gmail.com wrote:

   File pyshell#9, 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 scott.m...@gmail.com wrote:
 
 
 
    File pyshell#9, 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 scott.moore...@gmail.com 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 ian.g.ke...@gmail.com wrote:
 On Thu, Jul 18, 2013 at 5:04 PM, CTSB01 scott.moore...@gmail.com 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 scott.moore...@gmail.com  
wrote:



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

On Jul 18, 2013 4:23 PM, CTSB01 scott.m...@gmail.com wrote:



   File pyshell#9, 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 scott.m...@gmail.com wrote:






   File pyshell#9, 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 ian.g.ke...@gmail.com wrote:
 
  On Thu, Jul 18, 2013 at 5:04 PM, CTSB01 scott.moore...@gmail.com 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 torr...@gmail.com 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 
python-list-requ...@python.org




 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 pyshell#6, line 1, in module
phi_m(x, 2)
  File pyshell#2, 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 pyshell#6, line 1, in module
 phi_m(x, 2)
   File pyshell#2, 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 scott.moore...@gmail.com 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 pyshell#6, line 1, in module
 phi_m(x, 2)
   File pyshell#2, 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 scott.m...@gmail.com 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 pyshell#6, line 1, in module
 
      phi_m(x, 2)
 
    File pyshell#2, 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 pyshell#6, line 1, in module
 
   phi_m(x, 2)
 
 File pyshell#2, 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


[issue18488] sqlite: finalize() method of user function may be called with an exception set if a call to step() method failed

2013-07-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I think both (PyException_SetContext), as in Python code. See 
textiowrapper_close() in Modules/_io/textio.c for example.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18488
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18373] implement sys.get/setbyteswarningflag()

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 if
 (perhaps someone is calling your library and passing it the wrong type)
 they would be guarded against this common error.

OTOH, if your library is concerned about unwanted bytes objects, you can add an 
explicit type check.
That said, I don't see any counter-argument against this proposal; only that 
I'm not sure it's very useful.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18373
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18373] implement sys.get/setbyteswarningflag()

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't know why your patch is putting this in the thread state, though...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18373
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17911] Extracting tracebacks does too much work

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I think ExceptionSummary could be the visible API, instead of adding an 
indirection through a separate global function.
Also, I don't think having the exc_traceback list of tuples is future-proof. 
What if we want to add some information to each traceback entry, or refactor it 
to take __loader__ into account?
Instead, ExceptionSummary could expose the desired operations (e.g. iterate 
over traceback lines and the associated source code lines) without being 
constrained by some implementation details.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17911
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Is it common practice to ignore test files in coverage reports?
It sounds like not omitting them can help you find out if e.g. some tests are 
not run by mistake.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16611] multiple problems with Cookie.py

2013-07-18 Thread Julien Phalip

Julien Phalip added the comment:

I'm attaching a suggested patch to fix the issues relating to 
serializing/deserializing the httponly and secure flags. The main idea is that 
for a flag to be active, it needs to both be set and have the True value.

I think this is a much more correct and saner approach than the current 
implementation. As it's been discussed previously, currently the httponly and 
secure flag are systematically given the empty string as default value when 
instantiating a Morsel object. So one would infer that the empty string means 
that the flags are inactive. However, when deserializing a Morsel object, the 
empty string is used to indicate that a flag is active. Both behaviors 
contradict each other.

While the suggested change is backwards-incompatible, it would break the code 
of developers relying on an inconsistent behavior. So perhaps this might be 
compelling enough to allow breaking backwards compatibility in this case.

Let me know what you think. Thanks!

--
keywords: +patch
nosy: +julien.phalip
versions:  -Python 2.7
Added file: http://bugs.python.org/file30962/cookies-httponly-secure.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16611
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9177] ssl.read/write on closed socket raises AttributeError

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the patch, I will take a look.

--
stage: needs patch - patch review
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9177
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14518] Add bcrypt $2a$ to crypt.py

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Apparently, Django supports of variant of that format:
https://docs.djangoproject.com/en/1.4/topics/auth/#using-bcrypt-with-django

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18379] SSLSocket.getpeercert(): OCSP and CRL DP URIs

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Do you have to put those certs in capath? Things would probably be simpler if 
you didn't have to trigger capath loading using an actual SSL connection.
Also, please a versionadded tag in the doc entry.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18379
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18381] unittest warnings counter

2013-07-18 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +rbcollins

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18381
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18425] IDLE Unit test for IdleHistory.py

2013-07-18 Thread R. Jayakrishnan

R. Jayakrishnan added the comment:

Thanks Terry for we have the option of gui tests when mocking becomes too 
complicated

I put two separate classes IdleHistoryMockTest and IdleHistoryTKTest for mock 
and TK text usages and used TK Text to test IdleHistory.history_do function. 
This worked for me and hopefully IMHO the logic behind history_do is tested 
enough for now.

--
Added file: http://bugs.python.org/file30963/test_idlehistory2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18425
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17214] http.client.HTTPConnection.putrequest encode error

2013-07-18 Thread Vajrasky Kok

Vajrasky Kok added the comment:

The script for demonstrating bug can be simplified to:

---
import urllib.request
url = 
http://www.libon.it/ricerca/7817940/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-Käfer/order/date_desc;

req = urllib.request.Request(url)
response = urllib.request.urlopen(req, timeout=30)
the_page = response.read().decode('utf-8')
print(the_page)
---

Attached the simple patch to solve this problem.

The question is whether we should fix this problem in urllib or not because 
strictly speaking the url should be ascii characters only. But if the Firefox 
can open this url, why not urllib?

I will contemplate about this problem and if I (or other people) think that 
urllib should handle url containing non-ascii characters, then I will add 
additional unit test.

Until then, people can use third party package, which is
request package from http://docs.python-requests.org/en/latest/


r = 
requests.get(http://www.libon.it/ricerca/7817940/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-Käfer/order/date_desc;)
print(r.text)


--
nosy: +vajrasky
Added file: 
http://bugs.python.org/file30964/patch_to_urllib_handle_non_ascii_char_in_url.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17214
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18490] Error embedding datetime in C++

2013-07-18 Thread abdulet

New submission from abdulet:

Hi all,

I'm ebedding a python program into C++ ecap library. Everything works fine 
until I'v try to import sqlite3. When I try to import it I give the following 
exception:
Traceback (most recent call last):
', '  File /usr/local/squid/bin/putAdds.py, line 4, in module
import sqlite3
', '  File /usr/lib/python2.7/sqlite3/__init__.py, line 24, in module
from dbapi2 import *
', '  File /usr/lib/python2.7/sqlite3/dbapi2.py, line 24, in module
import datetime
', 'ImportError: /usr/lib/python2.7/lib-dynload/datetime.i386-linux-gnu.so: 
undefined symbol: PyExc_SystemError

So it seems that is a problem in datetime module. How can i solve that?

Thanks and regards
Abdul

--
components: Extension Modules
messages: 193280
nosy: abduelt
priority: normal
severity: normal
status: open
title: Error embedding datetime in C++
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18490] Error embedding datetime in C++

2013-07-18 Thread Christian Heimes

Christian Heimes added the comment:

Hello Abdulet,

the issue tracker isn't the best place to get help for your problem. May I 
suggest that you write a mail to the Python user list or one of the more 
specialized lists like the CAPI SIG and C++ SIG?

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

--
nosy: +christian.heimes
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14518] Add bcrypt $2a$ to crypt.py

2013-07-18 Thread Christian Heimes

Christian Heimes added the comment:

The crypt module is just a thin wrapper around crypt(3). Some operating systems 
have support for $2a$ but apparently I don't have one at home. Django uses 
https://code.google.com/p/py-bcrypt/source/browse/#hg%2Fbcrypt

http://linux.die.net/man/3/crypt

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18379] SSLSocket.getpeercert(): OCSP and CRL DP URIs

2013-07-18 Thread Christian Heimes

Christian Heimes added the comment:

It's just one certificate. The hash format of OpenSSL has changed over the 
years so we have to duplicate all certificates. But I don't need the extra 
stuff. I figured out that the Nokia test certificate has all new fields.

My initial patch has a versionchanged doc update. Did you have too much French 
wine again? *scnr* :)

--
Added file: http://bugs.python.org/file30965/ssl_ocsp_crldp2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18379
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18490] Error embedding datetime in C++

2013-07-18 Thread abdulet

abdulet added the comment:

Ok it looks like a bug for me, sorry for the inconveniences

Thanks and regards
Abdul

TECNOCOM

Abdul Pallarès Calvi

Técnico Especialista

Sistemas gestionados

Entença, 335

Barcelona 08029

Tel. Fijo: (+34) 934953167

Tel. Móvil / Fax: (+34) 647970296 / (+34)

email: abdul.palla...@tecnocom.es

http://www.tecnocom.es

Por favor, antes de imprimir este mensaje, asegúrate de que es necesario. 
Ayudemos a cuidar el medio ambiente
Este mensaje puede contener información confidencial o privilegiada. Si le ha 
llegado por error, rogamos no haga uso del mismo, avise al remitente y bórrelo. 
Consulte aviso legal
This message may contain confidential or privileged information. If it has been 
sent to you in error, please do not use it, notify the sender of the error and 
delete it. SPAN style=FONT-SIZE: 7pt; COLOR: gr


De: Christian Heimes rep...@bugs.python.org
Enviat el: dijous, 18 / juliol / 2013 13:13
Per a: Pallares Calvi, Abdul Sabur
Tema: [issue18490] Error embedding datetime in C++

Christian Heimes added the comment:

Hello Abdulet,

the issue tracker isn't the best place to get help for your problem. May I 
suggest that you write a mail to the Python user list or one of the more 
specialized lists like the CAPI SIG and C++ SIG?

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

--
nosy: +christian.heimes
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18490
___

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18490
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18379] SSLSocket.getpeercert(): OCSP and CRL DP URIs

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 It's just one certificate.

Indeed, it's just the decision to use capath that I'm arguing with.

 My initial patch has a versionchanged doc update. Did you have too
 much French wine again? *scnr* :)

Not *too much*, no ;-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18379
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17214] http.client.HTTPConnection.putrequest encode error

2013-07-18 Thread Christian Heimes

Christian Heimes added the comment:

The problem may not be a bug but a deliberate design choice. urllib is rather 
low level and doesn't implement some browser magic. Browsers handle stuff like 
'ä' - '%C3%A4', ' ' - '%20' or IDNA but urllib doesn't. I always saw it as 
may responsibility to quote and encode everything myself. Higher level APIs 
such as requests are free to implement browser magic.

Contrary to common believes an URL with an umlaut or space is *not* a valid 
URI. From 
http://docs.python.org/3/library/urllib.request.html#urllib.request.Request

 url should be a string containing a valid URL.

I suggest that this ticket shall be closed as won't fix.

--
nosy: +christian.heimes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17214
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18373] implement sys.get/setbyteswarningflag()

2013-07-18 Thread Daniel Holth

Daniel Holth added the comment:

On Thu, Jul 18, 2013, at 04:22 AM, Antoine Pitrou wrote:
 
 Antoine Pitrou added the comment:
 
 I don't know why your patch is putting this in the thread state,
 though...

If you have multiple threads one thread might want exceptions when
str(bytes), and the other might not.

str(bytes) has been an insidious problem for me. No exceptions,
seemingly working code, and b'' in serialized data. I am motivated to
turn it off.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18373
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18373] implement sys.get/setbyteswarningflag()

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

  I don't know why your patch is putting this in the thread state,
  though...
 
 If you have multiple threads one thread might want exceptions when
 str(bytes), and the other might not.

That sounds too much of a special case to me. You can still catch
BytesWarnings inside a context manager or something.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18373
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18468] re.group() should never return a bytearray

2013-07-18 Thread Ezio Melotti

Ezio Melotti added the comment:

I'm not sure it's worth changing it.
As I see it, match/search are supposed to work with str or bytes and they 
return str/bytes accordingly.  The fact that they work with other bytes-like 
objects seems to me an undocumented implementation detail people should not 
rely on.
If they are passing bytes-like object, both the current behavior (return same 
type) or the new proposed behavior (always return bytes) seem reasonable 
expectations.

IIUC the advantage of changing the behavior is that it won't keep the target 
string alive anymore, but on the other hand is not backward compatible and 
makes things more difficult for people who want the same type back.
If people always want bytes back regardless of the input, they can convert the 
input or output to bytes explicitly.

--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-07-18 Thread Brett Cannon

Brett Cannon added the comment:

The key problem with keeping them is that beginners might mistake that a test 
didn't run simply because some resource wasn't available when the tests were 
run (e.g. I forget to run the coverage report so I do it on an airport to the 
conference and have no Internet). Plus if you find this out you need to know 
hours in advance as a complete coverage run takes quite a while.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 The key problem with keeping them is that beginners might mistake
 that a test didn't run simply because some resource wasn't available
 when the tests were run (e.g. I forget to run the coverage report so
 I do it on an airport to the conference and have no Internet). Plus
 if you find this out you need to know hours in advance as a complete
 coverage run takes quite a while.

I don't understand what the problem is. The coverage shows you precisely
what was run and what wasn't. How is it a bug?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18468] re.group() should never return a bytearray

2013-07-18 Thread Matthew Barnett

Matthew Barnett added the comment:

There's also the fact that the match object keeps a reference to the target 
string anyway:

 import re
 t = memoryview(ba)
 t
memory at 0x0100F110
 m = re.match(ba, t)
 m.string
memory at 0x0100F110

On that subject, buried in the source code (_sre.c) is the comment:

/* FIXME: implement setattr(string, None) as a special case (to
   detach the associated string, if any */


In the regex module I added a method detach_string to perform that function.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18373] implement sys.get/setbyteswarningflag()

2013-07-18 Thread R. David Murray

R. David Murray added the comment:

I presume you mean you are motivated to turn it on (to catch the bugs).  I 
still think that also fixing the bugs in the other places str(bytes) is used 
would be better.  Are they occurring in third party libraries?  How often do 
you run into it?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18373
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17911] Extracting tracebacks does too much work

2013-07-18 Thread Björn Sandberg Lynch

Björn Sandberg Lynch added the comment:

I was trying to stay with the established pattern of the existing methods. 
There are two unrelated issues to solve here - deferring linecache access, and 
the extract_exception functionality.

When it comes to deferral, we could wrap each line in a different class than 
tuple, but this constitutes a public API change (and this is a *very* widely 
used library). Even changing to a namedtuple would cause a lot of grief, since 
we'd break lots of doctests, and subclassing tuple is a lot of effort for 
little benefit. If we only do it for the deferred usage, it would only be 
inconsistent. I suppose we could have a completely separate way of doing things 
for ExceptionSummary, but again, inconsistent, and I think if one extract_xxx 
method provides the functionality, users would expect it to be available in the 
others.

For ExceptionSummary, the same summary instance is used more than once if you 
have a cause set, so object creation had to be separated from the graph 
population. Either this is done in a constructor function or we would need some 
obscure tricks with the class kwargs. This way, there's a separation of 
concerns - the class wraps *one* exception, and the function creates a bunch 
and links them together as needed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17911
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18468] re.group() should never return a bytearray

2013-07-18 Thread Ezio Melotti

Ezio Melotti added the comment:

 match/search are supposed to work with str or bytes and
 they return str/bytes accordingly.

s/they return/calling m.group() returns/

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17911] Extracting tracebacks does too much work

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 When it comes to deferral, we could wrap each line in a different
 class than tuple, but this constitutes a public API change (and this
 is a *very* widely used library). Even changing to a namedtuple
 would cause a lot of grief, since we'd break lots of doctests, and
 subclassing tuple is a lot of effort for little benefit. If we only
 do it for the deferred usage, it would only be inconsistent. I
 suppose we could have a completely separate way of doing things for
 ExceptionSummary, but again, inconsistent, and I think if one
 extract_xxx method provides the functionality, users would expect it
 to be available in the others.

YMMV, but I think we should go for inconsistency here. The other APIs
in the traceback module are low-level and clearly limited by the type
of objects they return.

This feature request is a good opportunity to design something a little
more future-proof. I'd love to know what other developers/contributors
think here.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17911
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-07-18 Thread Brett Cannon

Brett Cannon added the comment:

The problem is confusing new contributors.

Why wasn't this test run?
Because you're not on OS X.
Why wasn't this run?
I didn't have internet at the time.

It's noise that's unnecessary. People should be focusing on the coverage of the 
modules in the stdlib and not the tests themselves. Plus the process takes so 
darn long already I don't think it's worth the time to waste on covering the 
tests as well.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16611] multiple problems with Cookie.py

2013-07-18 Thread John Dennis

John Dennis added the comment:

I think your basic approach is fine and it's O.K. to break backwards 
compatibility. I'm not sure anyone was using the httponly and secure flags in 
the past because it was so broken, the logic was completely contradictory, so 
backwards compatibility should not trump fixing obviously broken logic.

I didn't review your patch carefully, just a really quick glance. The one thing 
that did pop out was compiling the static regexp every time the function is 
called. Why not make it a module or class object and compile once at load time?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16611
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-07-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 The problem is confusing new contributors.
 
 Why wasn't this test run?
 Because you're not on OS X.
 Why wasn't this run?
 I didn't have internet at the time.

Well, you're trying to fix a symptom, rather than the underlying cause.
And the concept of skipped tests is quite basic, it shouldn't be very
hard to grasp.

 It's noise that's unnecessary. People should be focusing on the
 coverage of the modules in the stdlib and not the tests themselves.
 Plus the process takes so darn long already I don't think it's worth
 the time to waste on covering the tests as well.

Whether or not the report includes the test files shouldn't impact the
test runtime.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18491] Add exe wrapper functionality to Windows launcher

2013-07-18 Thread Paul Moore

New submission from Paul Moore:

Adds exe wrapper functionality to the Windows launcher. This is a preliminary 
patch, for comments - the code is there and works, but I need to add 
documentation (and maybe tests - are there any existing tests for the launcher?)

Also to be considered: should the launcher be bundled somewhere accessible to 
Python code (locating where the launcher has been installed is a non-trivial 
task) and supplementing that, should there be some sort of wrapper creation API 
in the standard library. The script wrapper functionality in distlib may be a 
good model for this, but may be too complex. I'd rather see this patch accepted 
without support code than see it deferred due to concerns about the 
quality/design of additional support code.

--
assignee: vinay.sajip
components: Windows
messages: 193300
nosy: pmoore, vinay.sajip
priority: normal
severity: normal
stage: patch review
status: open
title: Add exe wrapper functionality to Windows launcher
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18491
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18491] Add exe wrapper functionality to Windows launcher

2013-07-18 Thread Paul Moore

Changes by Paul Moore p.f.mo...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file30966/launcher_wrapper.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18491
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18491] Add exe wrapper functionality to Windows launcher

2013-07-18 Thread Paul Moore

Changes by Paul Moore p.f.mo...@gmail.com:


--
nosy: +tim.golden

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18491
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

I cannot reproduce the issue on Ubuntu.
As for the second exception I think it's safe to just do:

- raise URLError('ftp error: %d' % reason) from reason
+ raise URLError('ftp error: %s' % reason) from reason

(will commit that later)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18468] re.group() should never return a bytearray

2013-07-18 Thread Guido van Rossum

Guido van Rossum added the comment:

 Ezio Melotti added the comment:
[...]
 IIUC the advantage of changing the behavior is that it won't keep the target 
 string alive anymore, but on the other hand is not backward compatible and 
 makes things more difficult for people who want the same type back.

Everyone seems to be afraid of backward compatibility here. I will
take full responsibility, so let's just discuss what's the better API,
regardless of what we did (and in 99% of the cases it's the same
anyway).

People who want the same type back -- there is no evidence that
anyone wants this. People who want a bytes object -- this is
definitely a valid use case.

 If people always want bytes back regardless of the input, they can convert 
 the input or output to bytes explicitly.

But this requires an extra copy if the input is a bytearray. I suspect
this might be the most commonly used non-bytes non-str target in
Python 3 programs, and we are striving to support bytearray as input
in as many places as possible where plain bytes is accepted. But
generally getting bytearray as output requires a different API, e.g.
recv_into().

I think a very reasonable general rule is that for functions that take
either str or bytes and adjust their output to the input type, if
their input is one of the bytes alternatives (bytearray, memoryview,
array.array('b'), maybe others) the output is always a bytes object.

The reason is that while the buffer API makes it easy to access the
underlying bytes from C, it doesn't give you a way to create a new
object of the same type (except by slicing, which doesn't always
apply, e.g. os.listdir()). So for creating return values that match a
memoryview (or bytearray, etc.) input, the only reasonable thing is to
return a bytes object.

(FWIW os.listdir() violates this too -- os.listdir(b'.') returns a
list of bytes objects, while os.listdir(bytearray(b'.')) returns a
list of str objects. This seems caused by revesed logic -- it probably
tests if the type is bytes rather than if the type isn't str for
the output type, even though it does the right thing with the
input...)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18468
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Rock Lee

Rock Lee added the comment:

Bug in urllib/request.py.
format string formatted error type variable 

 2373 except ftplib.error_perm as reason:
 2374   raise URLError('ftp error: %d' % reason) from reason

variable reason here is a instance of class ftplib.error_perm.
We need to passed in a integer object. 

Patch supplied.

--
keywords: +patch
nosy: +rock
Added file: 
http://bugs.python.org/file30967/urllib-request-format-type-bug.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Rock Lee

Rock Lee added the comment:

Fixed like this:

raise URLError('ftp error: %d' % int(str(reason)[:3])) from reason

I think this is the original author's intention. 

Actually, need to fix two places in urllib/request.py

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

That's not safe as a misbehaving FTP server might not send a response code at 
all (highly unlikely but still...).
Furthermore having the complete server response (response code + accompaining 
message) is a lot more helpful.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17214] http.client.HTTPConnection.putrequest encode error

2013-07-18 Thread Vajrasky Kok

Vajrasky Kok added the comment:

I have no problem if this ticket is classified as won't fix.

I am writing this for the confused souls who want to use urllib to access url 
containing non-ascii characters:

import urllib.request
from urllib.parse import quote
url = 
http://www.libon.it/ricerca/7817940/3499155443/dettaglio/3102314/Onkel-Oswald-und-der-Sudan-Käfer/order/date_desc;

req = urllib.request.Request(url)
try:
req.selector.encode('ascii')
except UnicodeEncodeError:
req.selector = quote(req.selector)
response = urllib.request.urlopen(req, timeout=30)
the_page = response.read().decode('utf-8')
print(the_page)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17214
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17933] test_ftp failure / ftplib error formatting issue

2013-07-18 Thread Rock Lee

Rock Lee added the comment:

yes, the malformed server could do evil things.  If we need to cover this 
situation, we need to some extra fixes in this file. 

Maybe the exception message look like this is the better one ?
   ftplib.error_perm: 550 Failed to change directory

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17933
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >