Re: [Tutor] Start multiple threads from Python

2013-08-07 Thread Chris Down
On 2013-08-05 12:17, Ryan Waples wrote: > Currently I am calling each analysis program one at a time with > subprocess.call(). This is working without a hitch, but as each analysis > can take a while to run, I want to try to speed things up. I realize I can > start three different python sessions

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 18:36, Dave Angel wrote: > This version should be a bit cleaner than what I've seen on this thread. Our methods are almost the same, other than the fact that you don't use a generator, and you do the length validity check during the loop instead of preemptively, I'm not sure which I

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 03:48, Saad Javed wrote: > I want to add users to the tweet from the list, the no. of users added > based on the length of the tweet. It looks like you're using Python 2, but you didn't specify. I'd probably do something like this: #!/usr/bin/env python MAX_LENGTH = 140

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 19:42, Chris Down wrote: > All that needs to happen is to move the pop to the top of the MAX_LENGTH > check: > > while len(new_message) + len(add) <= MAX_LENGTH: ...or, better, remove the if...break and just do: while users and len(new_message) + len(add

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 14:40, Saad Javed wrote: > It will add max no. of users to one tweet until limit is reached. I want > all users added to the tweet. E.g. if 4 users can be added to the tweet > before reaching the limit, return three tweets...first two with 4 users > attached and the last one with thr

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 22:31, Saad Javed wrote: > Thank you for your response. This code has a bug. > > If there is one user left in the user list, it doesn't print a tweet with > just that one user added. For example use this string: "These are my > friends living in the same city as i am. I have known the

Re: [Tutor] adding users to tweets on a list

2013-08-07 Thread Chris Down
On 2013-08-06 22:49, Saad Javed wrote: > That causes: > > Enter string: These are my friends living in the same city as i am. I have > known them for years. They are good people in general. They are: > Traceback (most recent call last): > File "chris_tweet_len.py", line 44, in > print("\n".j

Re: [Tutor] Map function

2013-08-10 Thread Chris Down
Hi Phil, On 2013-08-10 16:45, Phil wrote: > The Arduino has a map function named "map" which looks like this: > > map(value, 0, 1023, 0, 100) > > The function, in this case, takes an integer value between 0 and > 1023 and returns a number between 0 and 100. Is there a Python > equivalent? The Ard

Re: [Tutor] [Python-Help] Instancing class issue

2013-08-12 Thread Chris Down
Hi Dino, On 2013-08-12 20:32, Dino Bektešević wrote: > def __init__(self, **keys): > from . import util > > self.keys=keys > self.load() > > where I don't understand what **keys mean, I've only seen that as **kwargs > meaning other key words and arguments in examples.

Re: [Tutor] Simple Python SNMP ping?

2013-08-15 Thread Chris Down
Hi Leam, On 2013-08-14 15:21, leam hall wrote: > Is there a way to do a simple check in Python to see if a remote host is > listening on SNMP port 161/UDP? "Simple" in this case could either mean technically simple (in which case, use a socket with SOCK_DGRAM and wait for data) or implementationa

Re: [Tutor] Error :SyntaxError: 'break' outside loop

2013-08-19 Thread Chris Down
On 2013-08-18 10:18, Zoya Tavakkoli wrote: > if k == 27: > > break Well, you're not in a function here, so break doesn't make any sense. What is it that you want to do? pgpYkuuMtY52T.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Error :SyntaxError: 'break' outside loop

2013-08-19 Thread Chris Down
On 2013-08-19 10:55, Chris Down wrote: > On 2013-08-18 10:18, Zoya Tavakkoli wrote: > > if k == 27: > > > > break > > Well, you're not in a function here, so break doesn't make any sense. What is > it that you want to do? s/function/loop/ pgpV

Re: [Tutor] http.server -- stuck at binding [windows8]

2013-08-19 Thread Chris Down
Hello, On 2013-08-18 10:40, shanmukhat...@gmail.com wrote: > I am developing a simple http media streamer with the help of simple http > server of http.server and I have a problem in binding the server. I get the > “the address is not valid in it’s content error” and I KNOW that it can be > solved

Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Chris Down
On 2013-08-20 18:40, Andy McKenzie wrote: > Well, since someone else brought it up... I really prefer top posting. In > general, I don't WANT to reread every message: I want to quickly get to > whatever is new. Right, which is why when top posting you should cut to the relevant context. > What

Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-20 Thread Chris Down
On 2013-08-21 01:01, Chris Down wrote: > Right, which is why when top posting you should cut to the relevant context. s/top posting/bottom posting/ I'm interested to know how you can reply and reference multiple parts of a message clearly when top posting, though. I think that'

Re: [Tutor] [OT] Replies go to individuals, not the list?

2013-08-21 Thread Chris Down
On 2013-08-21 10:30, Steven D'Aprano wrote: > - If there is nowhere I can reasonably trim their comments to establish > context, and my response is just a general reply rather than specifically > responding to specific comments (e.g. if my reply is "thanks for your email, > I'll consider it for the

Re: [Tutor] Runestone Python Course

2013-08-21 Thread Chris Down
On 2013-08-20 21:52, Jim Mooney wrote: > This is rather like W3 Schools That doesn't exactly fill me with confidence about the quality of it considering W3Schools is literally the cesspit of web standards misinformation... pgpV6o9SkFJaD.pgp Description: PGP signature

Re: [Tutor] library:

2013-08-21 Thread Chris Down
On 2013-08-21 13:31, Joel Goldstick wrote: > In python libraries are called modules I believe. So you may see > either term, and unless someone here corrects me, they are the same. They are often interchangeable, but they do not have to be the same (for example, it is perfectly imaginable that a

Re: [Tutor] library:

2013-08-21 Thread Chris Down
On 2013-08-21 23:30, Alan Gauld wrote: > It varies but in general programming terms is a collection of functions or > classes that can be reused by programmers. Most languages have a "standard > library" and a collection of additional proprietary libraries. Unless I'm misunderstanding, don't you m

Re: [Tutor] global variables

2013-08-22 Thread Chris Down
On 2013-08-22 13:36, Matthew Ngaha wrote: > I'm always told to avoid using them. I read discussions on the python > irc channel about them but honestly i feel there are some times where > i can't avoid using them. Like where i want to keep track of a state > variable in many different functions tha

Re: [Tutor] global variables

2013-08-22 Thread Chris Down
On 2013-08-22 14:43, Matthew Ngaha wrote: > I don't feel my program needs a class. Also i have been told to stop > using classes by some very experienced Python programmers on irc even > though i don't see why. It's confusing being told different things. Well, if you want to store state, you shoul

Re: [Tutor] global variables

2013-08-22 Thread Chris Down
On 2013-08-22 15:12, Matthew Ngaha wrote: > I am being totally honest here. I was very confused at the time and i said i > didn't agree because it's what i had put so much effort into learning. They > went on to say at some well known Python talks speakers have stated why using > OOP (especially in

Re: [Tutor] How much in a "try" block?

2013-08-22 Thread Chris Down
On 2013-08-23 06:20, Amit Saha wrote: > On Fri, Aug 23, 2013 at 6:14 AM, leam hall wrote: > > If I have a series of tasks that depend on X happening, should I put them > > all in the same "try" block or just put X in there and exit out if it fails? > > You are right about the latter. You should p

Re: [Tutor] How much in a "try" block?

2013-08-23 Thread Chris Down
On 2013-08-23 01:30, Alan Gauld wrote: > Unless you really only want g(x) executed if there is no MyError exception > but want h(x) executed regardless. I've had that situation a few times before when using the logic "try this, or fall back to this if it doesn't work". > I'm curious, how often do

Re: [Tutor] Python 3.x VIM

2013-08-24 Thread Chris Down
Hi Neelesh, On 2013-08-24 12:55, Neelesh Chandola wrote: > On your recommendation , I downloaded VIM but when checking for python 3.x > support , using :py3 print ("Hello") , it gives error E370 and E263. I also > checked :version and it shows that both py2.x and py3.x are in use . > So my questio

[Tutor] Resetting state of http.client/httplib HTTPSConnection objects

2013-08-25 Thread Chris Down
I am experiencing intermittent issues where an exception will be raised when calling getresponse(), which makes the entire connection stuck in Request-sent state. Is it possible to reset to idle state somehow without reinstantiating the HTTPSConnection? I ideally want to keep the connection to the

Re: [Tutor] Resetting state of http.client/httplib HTTPSConnection objects

2013-08-26 Thread Chris Down
On 2013-08-26 01:23, Alan Gauld wrote: > While this is technically within the remit of this list, since its > about a standard library module, I suspect you might be better > off asking on the main tutor list. It's at a deeper level of > skill/experience than most of the tutor queries. Hm, I guess

Re: [Tutor] Resetting state of http.client/httplib HTTPSConnection objects

2013-08-26 Thread Chris Down
On 2013-08-26 09:50, William Ray Wing wrote: > I'd be willing to bet that Alan simply foobar'd his answer - he _meant_ to > say the main python list, not the main tutor list. I guessed that was what he meant. I posted on python-list, anyway. pgpE1GejEhn4I.pgp Description: PGP signature _

Re: [Tutor] i need help with the following question

2013-08-26 Thread Chris Down
On 2013-08-26 01:29, isaac Eric wrote: > describe different ways of displaying output using python! Please, read this: http://www.catb.org/esr/faqs/smart-questions.html pgpmEMqlTiuCa.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.or

Re: [Tutor] Comment on http://www.catb.org/esr/faqs/smart-questions.html

2013-08-26 Thread Chris Down
On 2013-08-27 12:41, Steven D'Aprano wrote: > http://sscce.org/ "Keep the width of the lines in your example to under 62 characters wide." I don't really see any reason to use less than 79 in 2013. In my opinion(!), this document is too opinionated to be useful as a generic guide (but it mostly l

Re: [Tutor] Comment on http://www.catb.org/esr/faqs/smart-questions.html

2013-08-27 Thread Chris Down
On 2013-08-27 09:49, Alan Gauld wrote: > The reason for preferring shorter lines is to leave room for > the chevrons when the message gets quoted multiple times. I always reformat quotes with `gq' in vim when I am quoting, I suggest others do the same. pgp8Ve33ukc7A.pgp Description: PGP signatur

Re: [Tutor] Comment on http://www.catb.org/esr/faqs/smart-questions.html

2013-08-27 Thread Chris Down
On 2013-08-27 20:11, Steven D'Aprano wrote: > I wish mail clients would support rich text using ReST or Markdown. The > mail client could still include a GUI so you choose formatting commands > rather than have to type markup. Why can't you do this through your mailcap instead of relying on the

Re: [Tutor] os.system() not working

2013-08-27 Thread Chris Down
Hello, On 2013-08-27 16:03, Nitish Kunder wrote: > I have a python program which i am calling from a php script. > The arguments to the program is a path to the file > The program when directly run from console executes normally. > But when I try to execute the program from browser ie call the pyt

Re: [Tutor] os.system() not working

2013-08-28 Thread Chris Down
On 2013-08-28 08:16, wolfrage8...@gmail.com wrote: > PHP is not Python. You misread. > > I have a python program which i am calling from a php script. pgpqqKjmHTR5l.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] myown.getfilesystemencoding()

2013-08-30 Thread Chris Down
On 2013-08-30 08:04, Albert-Jan Roskam wrote: > In Windows, sys.getfilesystemencoding() returns 'mbcs' (multibyte code > system), which doesn't say very much imho. Well, what's the problem you have with mbcs being the output here? On NT, mbcs is the encoding that should be used to convert Unicode

Re: [Tutor] A mergesort

2013-08-31 Thread Chris Down
On 2013-08-31 22:00, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > def merge(a, b): > if len(a)*len(b) == 0: > return a+b Indentation in Python matters; if you're going to post code, you should probably keep it. > We have to look at the statement as > > v = ((a[0] < b[0] and a) or b).pop(0) This is short

Re: [Tutor] how to save variables after a user quits in python

2013-08-31 Thread Chris Down
On 2013-08-31 14:30, Jack Little wrote: > I am coding a game and I want the player to be able to quit the game and > immediately take off right from where they started from. If you're asking how to store variables between sessions, look at the pickle module. pgpWT4yz_VlbP.pgp Description: PGP si

Re: [Tutor] cs student needs help import math

2013-09-07 Thread Chris Down
On 2013-09-07 17:02, Byron Ruffin wrote: > I am writing a simple program based off an ipo chart that I did correctly. > I need to use ceil but I keep getting an error saying ceil is not defined. > I did import math, I think. I am using 3.2.3 and I imported this way... > > >>> import math > >>> mat

Re: [Tutor] Question about Functions

2013-09-10 Thread Chris Down
On 2013-09-10 13:34, novo shot wrote: > When I declare a variable to be equal as the fucntion > (result=theFunction("this either")) is Python also executing the function? You're not declaring it as equal, that would be `==' (or `is' for identity). `=' assigns, it doesn't check for equality. > The

Re: [Tutor] Python Programming Help

2013-09-11 Thread Chris Down
On 2013-09-10 21:01, Katie wrote: > In my NotePad file, I have the following...I'm not sure if I am even going > about doing this problem correctly... I don't envy you having to use notepad. Consider using a more sane editor... you'll thank yourself for it. > def sinh(x): > return (1/2)*(e^x

Re: [Tutor] AntiSpam measures circumventing

2013-09-23 Thread Chris Down
On 2013-09-20 15:50, Jugurtha Hadjar wrote: > I obviously don't like SPAM, but I just thought "If I were a > spammer, how would I go about it". You wouldn't, it's not effective to do this. You would just grab plain text e-mail addresses and leave it at that, anyone who tries to obfuscate their e-m

Re: [Tutor] AntiSpam measures circumventing

2013-09-24 Thread Chris Down
On 2013-09-25 13:54, Steven D'Aprano wrote: > And even that, I'm wondering if I'm being too cautious. Well, if you post on mailing lists, undoubtedly your e-mail has been posted in plaintext somewhere. I personally have my e-mail in plaintext on chrisdown.name, and very rarely receive spam through

Re: [Tutor] HELP I need help with Python Setup or to reach Marilyn Davis

2013-10-03 Thread Chris Down
On 2013-10-02 19:01, carolynn fryer wrote: > I am at the point where I am just spinning my wheels.  I tried to get help > with logging on but so far I am just getting frustrated. >   > I have a problem that I brought up the first night in class but couldn't seem > to get help then.  Sorry if I am a

Re: [Tutor] Writing Function Definitions

2013-10-09 Thread Chris Down
Hi Connor, On 2013-10-08 17:50, Connor Hood wrote: > Hi, I am taking a class in order to learn Python. One of the exercises I need > to do is write function definitions. I cannot figure out how to do one of > them. To show you an example here is a similar problem: > If m is an integer, then isP

Re: [Tutor] Writing Function Definitions

2013-10-09 Thread Chris Down
On 2013-10-09 11:28, Dave Angel wrote: > Alan's suggestions pretty much cover mine. Make your code readable, > rather than clever while you're learning. s/while you're learning// pgpjKcnwi1MeE.pgp Description: PGP signature ___ Tutor maillist - Tuto

Re: [Tutor] ImportError: 'DLL load failed: %1 is not a valid Win32 application.'

2013-10-11 Thread Chris Down
On 2013-10-10 16:04, Sreenivasulu wrote: > ImportError: 'DLL load failed: %1 is not a valid Win32 application.' > > Please help me how to run win32 modules in 64 bit . If I'm reading that correctly, that's not an error about running a 32-bit application in a 64-bit environment, but an error about