[Tutor] Design suggestion - is a cookie the answer?

2006-01-14 Thread Adam Cripps
ixing this? TIA Adam [1] http://www.monkeez.org/python/times.txt -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Design suggestion - is a cookie the answer?

2006-01-15 Thread Adam Cripps
ene in just presenting a URL to the browser? One of the 'cheats' was just putting the cursor within the URL bar and then pressing enter. Does Javascript pick this up as well? Many thanks again, Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Design suggestion - is a cookie the answer?

2006-01-17 Thread Adam Cripps
to look at this (such is the life of a teacher). Hopefully, this weekend, I may get the chance to. Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Mysql BLOB strangeness?

2006-03-17 Thread Adam Cripps
uot; + str(reportlist) + "" id = primary key, integer, not null title = varchar(255) content = blob published = char(1), default ='n' I've tried using looking at reportlist[0][2][1], but that just returns 'T' - which is obviously the T in 'This'. TIA Ada

Re: [Tutor] Mysql BLOB strangeness?

2006-03-17 Thread Adam Cripps
On 3/17/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Adam Cripps wrote: > > I'm trying to build a mini-CMS for my class to manage a single > > webpage, using CGI and mysql. The children will be storing their main > > content in a BLOB within a Mysql database.

Re: [Tutor] Mysql BLOB strangeness?

2006-03-17 Thread Adam Cripps
On 3/17/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Adam Cripps wrote: > > On 3/17/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Why are you using a BLOB when the content is text? > > > > I'm using BLOB because I want them to be able to write con

Re: [Tutor] Mysql BLOB strangeness?

2006-03-18 Thread Adam Cripps
On 3/17/06, Brian Gustin <[EMAIL PROTECTED]> wrote: > if the data is not binary, you can use TEXT type - accepts all readable > characters and data, BLOB type is more for binary data storage, and > MYSQL's Varchar type only stores up to 255 characters. (65,536 bits, or > 64Kbits) > > If you are sto

Re: [Tutor] Mysql BLOB strangeness?

2006-03-19 Thread Adam Cripps
| author | published | rejected | ++---+-++---+--+ | 1 | Test | This is a test | 0 | n | NULL | ++---+-++---+--+ 1 row in set (0.02 sec) (shame this doesn't monospace in Gm

Re: [Tutor] html and mod_python

2006-03-22 Thread Adam Cripps
. I'm not sure how to > do it, and I'm really hoping that someone can point me to the right direction. > > Thanks, > Patty > I've just done something similar with a radio button. You will need to query your database to find the value. Then with that value, you can have

Re: [Tutor] Mysql BLOB strangeness?

2006-03-25 Thread Adam Cripps
e what you will be working with :) Switching to a TEXT field in MySQL worked instantly. I think I understand the idea behind the iteration (almost iteration inside iteration). I did attempt it, but for some reason I couldn't get it to work. Perhaps I'm not at that level yet. Thanks guys.

[Tutor] Cleaning up input before inserting into MySQL.

2006-03-25 Thread Adam Cripps
ou have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'test'', '44')' at line 1") How do I insert these quotes without it closing the SQL statement prematurely? TIA Adam [1] def inse

[Tutor] Lists of lists - different sized lists

2006-05-19 Thread Adam Cripps
ep it above 0. Any help or advice would be appreciated. TIA Adam [1] def groups(pupils, size): toplist = [] tmplist = [] print len(tmplist) while len(pupils)>0: print len(pupils) while len(tmplist)<=size: print "tmplist is ", len (tmplist)

[Tutor] IDLE Crashing

2006-08-04 Thread Adam Gomaa
s), so I don't think it has anything to do with the actual files it's accessing. - #2006 Adam Gomaa, Public Domain listfiles=open('retrieves/list.txt','r') fileread=listfiles.read() ##reads list.txt and assings to fileread filelist=[] filelist=fileread.splitlines

Re: [Tutor] IDLE Crashing

2006-08-05 Thread Adam Gomaa
writes the list to an external file within the loop, so I won't have to deal with such huge lists inside idle. Thanks for everyone's help! Adam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] cylinder texture map?

2006-10-12 Thread Adam Bark
On 12/10/06, Danny Yoo <[EMAIL PROTECTED]> wrote: On Thu, 12 Oct 2006, Michael Shulman wrote:> I'd like to make a scrolling background for a game I'm working on.  I> was thinking, since it's all in orthographic view, that a horizontal> cylinder which rotates with a texture would simulate this very

[Tutor] Evaluate my script?

2006-10-23 Thread Adam Gomaa
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, -tutor. I wrote this script in chemistry class, which gets the user's input for various parts of the PV=nRT ideal gas law, then calculates the missing variable, which you indicate by putting in an 'x'. I've tried to follow 'best practices' per

Re: [Tutor] Evaluate my script?

2006-10-23 Thread Adam Gomaa
I'm sorry; I somehow lost a newline in copypasting. At about line #105, a newline is needed after "#return For loop" (this has been fixed on the HTML version that was linked before.) Adam Gomaa wrote: > Hello, -tutor. I wrote this script in chemistry class, which gets the

Re: [Tutor] Evaluate my script?

2006-10-24 Thread Adam Gomaa
attention to in the cases where you DO > care. I was afraid I hadn't commented enough! Well, now I know... Thanks again, Adam #!/usr/bin/python # Adam Gomaa, started Oct 24 2006 (finished same day) # An attempt to clean up/improve v2, with suggestions from the -tutor list. ""&q

Re: [Tutor] Question about exception handling

2006-12-17 Thread Adam Bark
: def exception_test(): raise Exception then start an interpreter and do the following import your_module try: ... your_module.exception_test() ... except: ... print "Caught it!" ... HTH, Adam ___ Tutor maillist - Tutor

[Tutor] Game server login encryption

2006-12-24 Thread Adam Bark
k the hash against one generated on the server. Alternatively I could use twisted conch tunneling through ssh. I anybody has any opinions on either of these ideas or anything else that might be useful, fire away. Cheers, Adam. ___ Tutor maillist - Tutor@

Re: [Tutor] Infinite Loops (and threads)

2006-12-24 Thread Adam Bark
sock.recv(1024) stackless.schedule() stackless.tasklet(get_data)(socket.socket(socket.AF_INET, socket.SOCK_DGRAM )) stackless.run() stackless thread things are really low on resources so you can run tens of thousands without too much trouble. HTH, Adam. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Game server login encryption

2006-12-25 Thread Adam Bark
Thanks a lot Bob that looks like a plan. Carlos I think the major problem with the SSL sockets is the lack of certificate checking which, I suspect, make it vulnerable to several exploits. Thanks anyway. Adam. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] python dictionaries

2007-01-05 Thread Adam Bark
tions in the dictinoary... could you perhaps put a dictinoary inside a dictionary? I don't understand how you would do the second part. Hopefully this will make sense to you as I don't want to give the whole game away. A grandfather is just a father's father. If you don't get

[Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Adam Cripps
ze of the list, when I have to have a fixed length. Is there a quick way of checking if a string is already within a list without iterating over the items of the list (which will slow the application down slightly)? TIA Adam -- http://www.monkeez.org PGP key: 0x711

Re: [Tutor] Removing duplicates in a list with a fixed length of items in the list.

2007-01-11 Thread Adam Cripps
On 1/11/07, Adam Cripps <[EMAIL PROTECTED]> wrote: > On 1/11/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > Adam Cripps wrote: > > > I have a list which comprises of simple random arithmetic problems for > > > teachers to give to their pupils. This list mus

Re: [Tutor] Psyco Puzzle

2007-01-12 Thread Adam Bark
On 11/01/07, Danny Yoo <[EMAIL PROTECTED]> wrote: > Sometimes psyco speeds up a script by a factor of 10, and sometimes > it makes no difference at all. Here's a case where I fully expected > it to make a difference: > . Whether using psyco > or n

[Tutor] Set changing order of items?

2007-01-19 Thread Adam Cripps
;ve realised that already I run the risk of having different problems (20 + 1 and 19 + 2) which have the same answer (21) which won't be allowed in the set. The whole code can be seen at[1]. TIA Adam -- http://www.monkeez.org PGP key: 0x7111B833 [1] def add (lowrange, hirange, i): &quo

Re: [Tutor] Set changing order of items?

2007-01-19 Thread Adam Cripps
On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote: > > I'm adding strings to a Set to prevent duplicates. However, the > > strings are meant to be in the correct order. When I add the string to > > the

Re: [Tutor] Set changing order of items?

2007-01-20 Thread Adam Cripps
On 1/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Adam Cripps wrote: > > On 1/19/07, Simon Brunning <[EMAIL PROTECTED]> wrote: > >> On 1/19/07, Adam Cripps <[EMAIL PROTECTED]> wrote: > >>> I'm adding strings to a Set to prevent duplicat

Re: [Tutor] Set changing order of items?

2007-01-21 Thread Adam Cripps
On 1/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Adam Cripps wrote: > > Many thanks all - I've got there in the end, using a tuple inside a > > set, ditching the question number and then rendering the sum for > > output in my main gui module. > > > >

Re: [Tutor] Send binary/hex data to a TCP socket

2007-01-24 Thread Adam Bark
On 25/01/07, Tod Haren <[EMAIL PROTECTED]> wrote: I need to send a server at the other end of a socket a 36 byte "frame", where each byte represents a specific field in the custom data structure.(If there are any Ham operators reading this, I'm talking about the AGW Packet Engine) The docum

[Tutor] Unpickling data after passing over the network

2007-02-11 Thread Adam Pridgen
Hello, I am having problems with unpickling data after I pass the data through a socket. Right now, I am pickling a basic string base 64 encoding and sending the data over the network. After the recipient client/server receives the data, it is decoded and then unpickled. The unpickling fai

[Tutor] Question about local scopes (namespaces)

2007-02-21 Thread Adam Pridgen
list foo, then the list is destroyed Is the my understanding correct? Thank you again for taking the time to review my question. --Adam def Bar(foo=[]): foo.append("newb got a keyboard\n") return foo if __name__ == "__main__": Bar() Bar() Bar() f = Bar()

[Tutor] what instance type is a function object?

2007-02-22 Thread Adam Pridgen
from. The below code throws an exception, because function is not a type. Presently I am attempting to do the following: def __getstate__( ret_val = {} for key in self.__dict__: if not isinstance(self.__dict__[key], function): pass # do assignment here Thanks a

[Tutor] Dictionaries of Tuples of Strings

2007-02-23 Thread Adam Pridgen
roken into individual characters. Thanks again, Adam. Output: name="years_of_newbness" type="xs:hexbinary" name="years_of_newbness" type="xs:integer" name="newb" type="x" name="newb" type="s" name="newb" type=&quo

Re: [Tutor] wav audio playback

2007-02-25 Thread Adam Pridgen
, but I am not sure about this. Some of the more Pythonic vets on the list might be able to provide feed back on that. However, from my past experience, regressing back to Python 2.4 seems to be the easiest and safest option in most cases. Regards, Adam On 2/26/07, Isaac <[EMAIL PROTECTED]>

[Tutor] executing a string representing python code

2007-03-05 Thread Adam Pridgen
ot;] print f("wasn't that cool!") When you exec the str, it will create a function object, and then you can obtain the object by accessing the object by kwd in the locals() dictionary. Guess it's not really magic, but I think it is still pretty cool ;) There also several vari

Re: [Tutor] Roman to digital (pseudocode)

2007-03-08 Thread Adam Bark
and the character before character Y is "C", add 900 to digital_result and remove that "C" and that "M" from the string. #How would you do *that*? and the character before character Y is another "M", or if character Y is the first character in the string,

[Tutor] kwds

2007-04-10 Thread Adam Pridgen
l with the * or **? Sometime ago I found something explaining the basics of these parameters, but I lost the link and I lost that warm and fuzzy feeling I had about them ;). Thanks in advance, Adam ___ Tutor maillist - Tutor@python.org http://mail.

Re: [Tutor] Interactive physics simulation over web

2008-04-04 Thread Adam Bark
> page<http://wiki.python.org/moin/WebProgramming>but it didn't answer my > questions. My goal is keep this simulation > completely written in Python. I think you can use Jython in a Java applet, that might be what you're looking for. HTH, Adam.

[Tutor] Dictionaries or Numpy?

2008-05-16 Thread Adam Clarridge
sing the board array many many times. I guess my question is: Is there any way to test Dictionary access time vs. Numpy array access time? Thanks, Adam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Dictionaries or Numpy?

2008-05-17 Thread Adam Clarridge
On 5/16/08, John Fouhy <[EMAIL PROTECTED]> wrote: > > On 17/05/2008, Adam Clarridge <[EMAIL PROTECTED]> wrote: > > I'm fairly new to Python, and I am not sure whether it would be faster > > for me to use a Dictionary data type to represent the board > >

Re: [Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread Adam Bark
elling python to handle > this large number in HEX instead which would fit into the 32 bit limit? > > thanks in advance, > > John T The L stands for long integer and means that it will usually use twice the space of a regular integer so in this case 64bits. HTH Adam. ___

Re: [Tutor] power of 2.718282

2009-01-13 Thread Adam Bark
According to a quick interactive session and the timeit module it's quicker to do 2.71828**10 than using math.exp, I'm guessing cos of the function call. >>> t=timeit.Timer("2.718282**10") >>> t.repeat() [0.073765993118286133, 0.066617012023925781, 0.06807398796081543] >>> t=timeit.Timer("math.exp

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 21:51, Jeff Goodwin wrote: Hello, I'm trying to find a way to use the random.randint function to generate a random number, but everytime I run the program it locks up IDLE. Here is what I have so far: import random def main(): x = input("Enter a number: ") y = input("Ente

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 22:10, Jeff Goodwin wrote: Ok, I found the problem, I had saved the file as random.py looks like that was a no-no. Its working now that I changed the name. Thanks! Jeff Ah yes always avoid giving your modules names that appear in the standard library. It goes wrong, sometimes in un

Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread Adam Bark
On 01/12/10 01:00, John Smith wrote: Hi, Walter - I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm guessing that the AMD versions are for the AMD processor). However, all of the exe offerings have the same "Python not found in registry" problem that started this whole thing

Re: [Tutor] role playing game - help needed

2010-12-07 Thread Adam Bark
re is a built in function for summing all the values in a sequence, it's called "sum". HTH Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] calling a method within a function

2010-12-07 Thread Adam Bark
On 07/12/10 22:36, John wrote: Hello, I have a strange problem with a piece of code I've written. It's a bit overly complicated to make an example with, but the gist is below. But in the example below, it works. However, in my example, when I call the method from within the function, it returns

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-09 Thread Adam Bark
r 1 In [6]: val Out[6]: 1 You are right by the way and I know you can't test every possibility but, as you already suspected the outcome, this just reinforces it I think. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or chan

[Tutor] paramiko error with put()

2010-12-23 Thread Adam Cryer
Hi I am using paramiko 1.7.6 "fanny" on microsoft windows xp v2002 service pack3 with python 2.4.2 I have the follwing script: *import paramiko hostname='blah' port=22 username='blah' password='blah' fullpath='root\\path\\file.xls' remotepath='/inbox/file.xls' self.client= paramiko.SSHClient

Re: [Tutor] question regarding regular expression compile

2011-01-12 Thread Adam Bark
ackslashes to give you a backslash character. So your re should now look like this: test = re.compile(r"MAT file (log|billing|util|carrier)\\\d{8} deleted") HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opti

Re: [Tutor] Concatenating string

2011-02-22 Thread Adam Bark
it as a string. Thus when you do a=bin(0xff0)+bin(0xff1) you are concatenating the two strings returned by bin. For d you are carrying out the mathematical addition operation on the two numbers before converting it to binary. 2) You've already done that several times, just use bin() HTH, Adam

Re: [Tutor] multiple if and or statement

2011-03-14 Thread Adam Bark
./testing.py true true true I know I am missing something, but in reality it should only print true once correct? Any string that isn't blank ie '' is true. In your test you've asked whether i == 'test1' is true or 'test2' is true not i == 't

Re: [Tutor] lambda

2011-03-19 Thread Adam Bark
s it many times. Map is another that works similarly. Have a look into functional programming as that's the branch of computer science those two functions and lambdas tend to come from I believe. http://docs.python.org/library/functions.html?highlight=lamb

Re: [Tutor] after(), how do I use it?

2011-04-25 Thread Adam Bark
re still confused post it and hopefully we can clear it up for you. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread Adam Lucas
On Wed, May 4, 2011 at 13:31, Spyros Charonis wrote: > Hello everyone, > > I have written a program, as part of a bioinformatics project, that > extracts motif sequences (programmatically just strings of letters) from a > database and writes them to a file. > I have written another script to anno

[Tutor] Beginner needs help with tkinter and images

2011-05-17 Thread Adam Westrum
I've got a basic program going right now, with 4 buttons. Forward backward right and left. Each button goes to an image of a colored circle. Problem i'm having is that when you click a button, the picture appears. When you click another button, a different picture appears, but the first picture rem

Re: [Tutor] Clunky Password maker

2011-05-25 Thread Adam Bark
On 25/05/11 19:54, Modulok wrote: Depending on what your passwords are going to be protecting, be aware that the default generator in the random module is: "...completely unsuitable for cryptographic purposes." If he's just planning on making a few passwords I think the period of 2**19937-1 of

[Tutor] Conceptual Question About Use of Python for Employee Training Program

2011-06-25 Thread Adam Carr
Good Morning: I am very new to Python but I am enjoying the learning process. I have a question about the application of Python to a problem at the industrial business where I work. My two main questions are: 1. Can Python be used to achieve the goals of the possible project? 2. Where are the

Re: [Tutor] serial device emulator

2011-07-05 Thread Adam Bark
oo.py ## import myserial as serial #import serial ## Use this in production port = serial.Serial() port.open() print port.write("hello, world") print port.read(3) I hope that makes it clearer to you. Adam. P.S. none of that code has been tested On 05/07/11 13:03, Edgar Almonte wrote:

Re: [Tutor] OT: Drag and Drop GUI IDE ideas

2011-07-28 Thread Adam Bark
presentation of your program as well as access to the source code of your application. It creates code for many different platforms including mobile ones and it's DRM free. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-08 Thread Adam Gold
I have short piece of code I'm using to print a string to the terminal one letter at a time.  It works fine when I invoke the script from within Idle; each letter appears after the preceding one according to the designated time interval.  However if I run it in the Mac terminal ('python3 ./scri

Re: [Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-09 Thread Adam Gold
> Date: Sun, 8 Jan 2012 23:34:15 + > From: Adam Gold > To: > Subject: [Tutor] different behaviour in Idle shell vs Mac terminal > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > > I have short piece of code I'm using to print a

Re: [Tutor] Extremely simple question

2012-01-11 Thread Adam Stogner
You should be using double quotes on this line and you are missing the last quote: print 'You're not Chris! Should be: print "You're not Chris!" On Wed, Jan 11, 2012 at 8:17 AM, col speed wrote: > On 11 January 2012 20:11, Max S. wrote: > > I believe that line 3 raises an error. The becaus

[Tutor] ssh socks proxy

2012-05-16 Thread Adam Gold
I'm trying to write a 'simple' script that will set up a socks proxy over ssh and maintain the connection until manually terminated. It's not possible to use key-based authentication so a password will need to be supplied. Also, note, the user is presented with a list of servers to choose fro

Re: [Tutor] ssh socks proxy

2012-05-17 Thread Adam Gold
me script would look like if one used paramiko? On 17 May 2012, at 04:01, kushal.kumaran+pyt...@gmail.com wrote: kushal.kumaran+pyt...@gmail.com wrote: > Adam Gold wrote: > >> I'm trying to write a 'simple' script that will set up a socks proxy >> ove

[Tutor] Need help with one problem.

2017-02-15 Thread Adam Howlett
Write an if-else statement that assigns 20 to the variable y if the variable x is greater than 100. Otherwise, it should assign 0 to the variable y. Is there an easy way to solve this problem? ___ Tutor maillist - Tutor@python.org To unsubscribe or ch

[Tutor] Python Help

2014-04-09 Thread Adam Grierson
Hi I'm using 3D climate data (ending in “.nc”). The cube contains time, longitude and latitude. I would like to look at the average output over the last 20 years. The time field spans back hundreds of years and I only know how to collapse the entire field into a mean value. How can I tell py

[Tutor] pipes and redirecting

2014-05-27 Thread Adam Gold
I'm trying to run the following unix command from within Python as opposed to calling an external Bash script (the reason being I'm doing it multiple times within a for loop which is running through a list): "dd if=/home/adam/1 bs=4k conv=noerror,notrunc,sync | pbzip2 > 1.i

Re: [Tutor] pipes and redirecting

2014-05-28 Thread Adam Gold
> On 27/05/14 21:01, Adam Gold wrote: > >> "dd if=/home/adam/1 bs=4k conv=noerror,notrunc,sync | pbzip2 > 1.img.bz2" >> >> The first thing I do is break it into two assignments > > And that's the start of the problem because it should be three:

[Tutor] gnupg within a for loop

2014-06-01 Thread Adam Gold
e it would have to be inputted by the user). I start with the following which can be used to encrypt a single file (assume I have the indentations correct in the actual code, I can't seem to modify the wrapping with my email client): phrase = '12345' cipher = 'AES256' gp

Re: [Tutor] gnupg within a for loop

2014-06-02 Thread Adam Gold
On 01/06/14 18:28, Danny Yoo wrote: > Hi Adam, > > Ah; I've seen this before. Make sure the file name is either relative > to current working directory, or make the file name absolute. What's > happening is that os.listdir() is giving you file names that are > re

Re: [Tutor] gnupg within a for loop

2014-06-02 Thread Adam Gold
On 02/06/14 01:35, Danny Yoo wrote: >> Thanks Danny, that was spot on. I actually used os.chdir to change to >> the base directory (which I assigned to a variable) just before the open >> statement. I don't know if that's 'pythonically' correct but it seemed >> like a simple way to do it. Again,

[Tutor] code review

2014-06-10 Thread Adam Gold
Hi there. I've been writing a script that is now finished and working (thanks, in part, to some helpful input from this board). What I'd really like to do now is go through it with an 'expert' who can point out ways I may have been able to code more efficiently/effectively. I don't think it woul

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
On 11/06/14 00:04, Steven D'Aprano wrote: > On Tue, Jun 10, 2014 at 04:51:20PM +0100, Adam Gold wrote: >> Hi there. I've been writing a script that is now finished and working >> (thanks, in part, to some helpful input from this board). What I'd >> really lik

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
n learn is by listening in to other people's > conversations - it's called lurking, I believe. > > So I would say, please do this on the list, and many more people than > Adam may benefit. Others can ignore the thread if they wish. > > Bob Oke doke, here it is below. Just for c

Re: [Tutor] code review

2014-06-13 Thread Adam Gold
On 12/06/14 00:38, Alan Gauld wrote: > > HTH Thanks Alan and Lukáš for your very helpful comments. I will attempt to revise the script in light of them and will revert if I hit any brick walls :) ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Adam Jensen
On 10/18/2014 02:36 PM, George R Goffe wrote: > Hi, > > When you run a python program, it appears that stdin, stdout, and stderr are > opened automatically. > > I've been trying to find out how you tell if there's data in stdin (like when > you pipe data to a python program) rather > than in a

[Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
I'm tinkering this evening and I've noticed that math.factorial() is much faster than my plain python implementations. import math def factorial(n): temp = 1 for k in range(0,n): temp = temp * (n - k) return(temp) def fac(n): r

Re: [Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
On 10/24/2014 08:01 AM, Stefan Behnel wrote: > Alan Gauld schrieb am 24.10.2014 um 13:03: >> Not all library modules are C based however so it doesn't >> always apply. But they are usually optimised and thoroughly >> debugged so it is still worth using them rather than building >> your own. > > I

[Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
Hi, I'm exploring Popen today and I seem to be having some trouble deciphering the [documentation][1]. [1]: docs.python.org/3/library/subprocess.html#popen-constructor In this example (below), I expect to start a shell script as a separate process, send a line of text through a pipe (to the shell

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere / >> somehow. Does anyone have any ideas about what it is that I might be >> misunderstanding? > > Works here

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 07:12 PM, Alan Gauld wrote: > On 27/10/14 18:24, Adam Jensen wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere > > It works fine on my Lubuntu 14 with Python3.4.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere / >> somehow. Does anyone have any ideas about what it is that I might be >> misunderstanding? > > Works here.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 09:31 PM, Alan Gauld wrote: > On 27/10/14 20:26, Adam Jensen wrote: > >> That's a bit bizarre. I too have the execution bit set for both the >> python script and the shell script but the same (no joy) behavior occurs >> on both: > >> $ ./subpr

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
Update: On 10/27/2014 09:50 PM, Adam Jensen wrote: > What's weird is that I have two different python3.4 installations on > this CentOS-6.5 machine and both have the same behavior (script hangs > until Ctrl+C). > > I built this one (/opt/bin/python3.4) from source

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 02:32 PM, Alan Gauld wrote: > I tried -1 and 1 on my Lubuntu and it still works fine. > Definitely weird, it begins to look like a CentOS build issue > but what is CentOS doing different to Lubuntu/Suse/OpenBSD etc? > > From memory CentOS is basically a free version of Red Hat > Ent

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 04:27 PM, Todd wrote: > Centos has SELinux enabled by default. I dont know if SELinux is > causing your problem, but it is always worth looking at. > > SELinux can keep a process from accessing files or executing another > process. > > Try temporarily disabling SELinux by runnin

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
#!/usr/bin/env python3.4 good = False s = input('Enter a number: ') a = s.split('.') n = len(a) if n <= 2: for y in a: if y.isdigit(): good = True else: good = False exit else: good = False if good: num = float(s) print(num * 12) e

Re: [Tutor] Data chart

2014-11-20 Thread Adam Jensen
import fileinput def parseLine(a): x = a.split('/') b = x[1].split(':') c = b[0].split('.') y = c[0] z = int(b[2]) return x[0], y, z print('{:>4}{:>10}{:>8}{:>8}'.format('','canofica','lnvd','msd')) data = [0, 0, 0] prevDate = "None" for line in fileinput.input():

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
On Thu, 20 Nov 2014 21:20:27 + Stephanie Morrow wrote: > Hi there, > > I have been posed with the following challenge: > > "Create a script that will ask for a number. Check if their input is a > legitimate number. If it is, multiply it by 12 and print out the result." > > I was able to do

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Adam Jensen
> -Original Message- > From: Tutor [mailto:tutor-bounces+hanzer=riseup@python.org] On > Behalf Of Alan Gauld > Sent: Thursday, November 20, 2014 7:24 PM > But that's considered bad practice, it's better to put the valid errors only in > the except line like this: > > try: > print

[Tutor] pexpect interactive password entry for luks device

2014-11-24 Thread Adam Gold
I'm trying to do something really simply (I think) with pexpect but must be missing an obvious step. I want to ssh from host to guest, establish a CIFS connection on the guest to a share somewhere else on the local network, open a luks loop device on the share by entering the password (I don't wan

Re: [Tutor] Memory management in Python

2014-12-09 Thread Adam Jensen
On Wed, 26 Nov 2014 14:08:53 + Raúl Cumplido wrote: > This web is quite useful to visualize what is happening: > http://www.pythontutor.com/visualize.html#mode=edit > Very nifty web app, thanks for the link! ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Need help!

2014-12-13 Thread Adam Jensen
On Fri, 12 Dec 2014 07:46:05 -0500 Jagannath Ramanan wrote: > My name is jag. I need little bit of help understanding something. I have a > vncserver running at the background in redhat. My client is lubuntu where > im using python. > > For some reason the communication is only possible between

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Fri, 19 Dec 2014 00:55:49 + Alan Gauld wrote: > You could have used a list instead of all the > individual variables > > line[0] = ... > line[1] = ... > > But then you could get clever and use a loop: > > while lines != 0: > start = 1 > period = 7 > for lineNum in range(7):

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Thu, 18 Dec 2014 20:27:03 -0500 Adam Jensen wrote: > And to build the 'lines' list (although, this is getting rather ugly): > > >>> lines = [[random.randint(x,x+6) for x in range(1,50,7)] for i in range(7)] Oops, in the context of the original program this might

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-19 Thread Adam Jensen
On Fri, 19 Dec 2014 10:32:15 +0100 Peter Otten <__pete...@web.de> wrote: > Basically > > from random import randint, seed > > is equivalent to > > import random > randint = random.randint > seed = random.seed > del random > > From that you can deduce that the whole random module is loaded int

Re: [Tutor] Learning to program, not code.

2014-12-21 Thread Adam Jensen
On Sun, 21 Dec 2014 21:15:43 +1100 Ben Finney wrote: > Use a distributed version control system > (Mercurial is good and is written in Python) I'm beginning to really appreciate [fossil](http://fossil-scm.org/). Re: "Learning to program, not code". Is that like learning to think rather than

<    1   2   3   4   >