I was looking at the example code below. I am using python 2.7.
I am wondering why when I substitute the while n! = "guess" to while n!= guess
(<-- no quotes) I get a problem?
The Type string is used for the first conditional comparison in the outer While
loop, but afterwards the Type is an int
Apr 29, 2015 at 09:44:28AM +, Ian D wrote:
>
>> I was looking at the example code below. I am using python 2.7.
>>
>> I am wondering why when I substitute the while n! = "guess" to while
>> n!= guess (<-- no quotes) I get a problem?
>
> Really? What s
Hello
I have some weird results when I run my code which is meant to display a canvas
and a turtle and some text with the turtles coordinates.
Basically the turtle coordinates do not seem to correspond with the TK
create_text coordinates.
t1.goto(100,100)
canvas_id = cv1.create_text(t1.x
if I create a module called "modtest.py" like this:
import turtle
def square():
for i in range(4):
turtle.fd(100)
turtle.lt(90)
def tri():
for i in range(3):
turtle.fd(100)
turtle.lt(120)
if __name__ == "__main__":
tri()
And then call it
Hi
is
import longModuleName as lmn
or
lmn = longModuleName
creating an alias or assigning to a variable. or both?
Thanks
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscripti
Hi
Another quickie.
I can create turtle objects (if that's the correct terminology) using 2
different ways, both work.
t1 = turtle.Turtle()
or
t2 = turtle
But which is the best practice... and why?
import turtle
t1 = turtle.Turtle()
t2 = turtle
t1.fd(100)
t2.goto(-100,100)
I notice that until a program has been run once, and I presume loaded its
imports, I cannot use auto completion.
I don't suppose there is a way to have it load modules in a way that would give
me access to the module functions straight away other than running the program
I presume there is no
Hi
Is it better to use python 3 as a newcomer who isn't really going to be writing
any software as such just using it for learning?
Also in 2.7 I use no subprocess by giving my python exe a -n argument,
otherwise my canvas program's freeze.
Is this needed also in version 3?
Ta
Hi
Are there any recommendations for python ide's
currently I am using idle, which seems pretty decent but am open to any
suggestions
cheers
___
Tutor maillist - Tutor@python.org
To unsubscribe or chang
Thanks for all the responses
I was mainly looking for a more user friendly ide in a windows environment with
things like command completion etc. Like something a novice might use. I
suppose vi is simple and available for windows but I don't suppose there would
be command completion even in vi
Hello
I used to use 2.7 and the input was pretty when inputting a numeric value, it
would just get cast to an int.
Seems that 3.3 I have to cast each input so :
float(num1 = input("Enter a number")
Is this just they way it is now? Is there a way to get back to just typing:
num1 = input("Ent
num1 = float(input("enter a number "))
I meant
not
float(num1 = input("Enter a number"))
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org
Hi
Are:
<=
==
!=
simple conditionals statements, conditionals, comparison operators, conditional
expressions or what?
I am looking at a few different pages and am unsure what I should be calling
these expressions.
http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/ifstatements.html#s
Hi
Seem when I run a module I created with
import sys
sys.path.append("d:\modules")
import myMod
it works great in 2.7
but in 3.3 it doesn't
I get an error in 3.3:
import myMod
ImportError: No module named 'myMod'
I have tried it with append("d:\\modules") append("d:/\modules")
A
Ok I seem to be having some success with it at the moment after moving the
location of the module.
From: dux...@hotmail.com
To: tutor@python.org
Date: Wed, 5 Feb 2014 11:09:35 +
Subject: [Tutor] sys.path.append import python3 not working
Hi
Seem when I run a module I created with
imp
not working
Ian D Wrote in message:
>
> import sys
> sys.path.append("d:\modules")
> I have tried it with append("d:\\modules") append("d:/\modules")
The first form is not reasonable, you'd need to double the
backslash. But your second tr
Hi
In Python 2.7
If I create my own modules and call them with
import sys
sys.path.append("d:\modules")
import myMod
and use tab to autocomplete I get a list functions.
myMod.< if I tab this I get a list of my functions
(This only works if I have ran program at least once, then
not working
>
> On 05/02/2014 11:46, Ian D wrote:
> > Ok even more strangely it is working in the original location.
> >
> > Am now not 100% sure that I have the folder structure correct.
> >
> > I will keep a eye on it.
>
> You might want to con
I am trying to exit a while loop whilst using turtle graphics.
I don't seem to have the logic correct at all.
I have tried a few different things
These might seem a bit illogical to you guys but to me they make some sense,
sadly
I just don't really grasp these while loops and their usage.(obviou
Thanks for the help on the last one.
Is it possible to restart a while loop? This doesn't work at all (surprise
surprise)
import turtle as t
def start():
global more
more = True
def stop():
global more
more = False
more = True
while True:
while more:
t.onkey(
a turtle gui program?
> To: tutor@python.org
> From: __pete...@web.de
> Date: Tue, 11 Feb 2014 14:01:47 +0100
> Subject: Re: [Tutor] can I make a while loop true again
>
> Ian D wrote:
>
>> Thanks for the help on the last one.
>>
>> Is it possible to res
I am trying to follow some code. It is basically a python scratch interfacing
script.
Anyway part of the script has this code.
Searching google for >> greater than signs in code with python has its issues.
Can anyone clarify this stuff.
I know its about 4 bytes of data. It looks like
Can anyone clarify please?
Just reading this:
https://wiki.python.org/moin/BitwiseOperators
The section on 2's complement binary for negative integers.
It states:
"Thus the number -5 is treated by bitwise operators as if it were written
"...111011". "
I am wondering why
Ok I am getting somewhere with this now.
A bitshift followed by ANDing the result of the shift!
So I think n>> 24 & 0xFF
is
shift n 3 bytes right, save results in n and then AND n with 255 decimal?
> From: dux...@hotmail.com
> To: tutor@python.org
But what is the purpose of ANDing with 255?
Would this not just return the same value?
eg 1010 and with would just return 1010 or 1010
> From: dux...@hotmail.com
> To: tutor@python.org
> Date: Thu, 1 May 2014 09:53:15 +
> Subject: Re
Hi
I have this part of code and am unsure as to the effect of the array('c') part.
Is it creating an array and adding 'c' as its first value?
This does not seem to be the case.
Thanks
n = len(cmd)
a = array('c')
a.append(chr((n>> 24) & 0xFF))
a.append(chr((n>> 16) & 0
Thanks
> To: tutor@python.org
> From: breamore...@yahoo.co.uk
> Date: Thu, 1 May 2014 16:40:54 +0100
> Subject: Re: [Tutor] array('c')
>
> On 01/05/2014 15:38, Ian D wrote:
> > Hi
> >
> > I have this part of code and am unsure as to the effect of th
I was reading a tutorial that had these examples in it:
>>> while False:
print("False is the new True.")
>>> while 6:
print("Which numbers are True?")
while -1:
print("Which numbers are True?")
while 0:
print("Which numbers are True?")
Unfortunately the author never explained
Or should I have said While False is True, which is never True, because False
is False not True
> From: dux...@hotmail.com
> To: tutor@python.org
> Date: Tue, 20 May 2014 08:25:48 +
> Subject: [Tutor] While truth
>
> I was reading a tutorial that had t
A while back some one linked to the python source and I was able to view the
whole of its libraries and class files something like this java api site
http://docs.oracle.com/javase/7/docs/api/
But I cant seem to find what I want now.
I wanted to be able to look at the classes etc
Anyone help
om: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] python libraries online
>
> On Thu, Jun 19, 2014 at 12:18:35PM +, Ian D wrote:
>
>> A while back some one linked to the python source and I was able to
>> view the whole of its libraries and class files som
online
>
> On Thu, Jun 19, 2014 at 12:18:35PM +, Ian D wrote:
>
>> A while back some one linked to the python source and I was able to
>> view the whole of its libraries and class files something like this
>> java api site http://docs.oracle.com/javase/7/docs/api/
>
What does top post mean?
> To: tutor@python.org
> From: breamore...@yahoo.co.uk
> Date: Thu, 19 Jun 2014 13:46:03 +0100
> Subject: Re: [Tutor] python libraries online
>
> On 19/06/2014 13:37, Ian D wrote:
>> And I wondered what &
> Date: Fri, 20 Jun 2014 00:30:49 +1000
> From: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] python libraries online
>
> On Thu, Jun 19, 2014 at 12:59:58PM +, Ian D wrote:
>> What does top post mean?
>
When trying to write my dictionary to a file I get:
f.write(output)
TypeError: 'tuple' does not support the buffer interface
using this example:
#so far this should read a file
#using dictreader and take a column and join some text onto it
import csv
csvfile= open('StudentListToSort.csv
This is driving me nuts.
I have tried many different things, but I just do not understand this csv
library.
I have tried passing various parameters to the writerow method and I am really
getting nowhere fast.
I just want to read from a file, join text to column and write to file.
The wr
Thanks for your help
I am not much closer in understanding this so I am going to try and start with
a simpler example for myself.
I will try and write some values to a file as I am struggling even doing this.
TypeError: 'str' does not support the buffer interface
TypeError: 'tuple' does not
Thanks
>
> Nonetheless, having re-read your question and having googled a bit, it
> seems that your problem might be related to Python 2 vs. Python 3, see
> here:
> http://stackoverflow.com/questions/24294457/python-typeerror-str-does-not-support-the-buffer-interface
>
> In short: In Python 2 you
Ok making some progress by changing the 'wb' to 'w'
>
> Ok I see this error and the example shows a different type of syntax.
>
>
> Rather than a file open for writing:
>
> outfile = open('output.csv', 'wb')
>
>
> it uses
>
> with open('data.csv', 'w', newline='') as out:
>
>
>
> now is this writ
>
> Ok making some progress by changing the 'wb' to 'w'
>
err no.
unstuck again.
import csv
csvfile= open('StudentListToSort.csv', newline='')
spamreader = csv.reader(csvfile,delimiter=',',quotechar='|')
outfile = open('outfile.csv','w')
for row in spamreader:
if row[4] == '6':
Thanks a lot this is really helpful as have been the other posts.
>
> Have you tried reading the documentation? It sounds like you're just
> throwing random bits of code at it and hoping something works.
>
> A better approach is to slow down and try to understand what the csv is
> doing, what it
>>
>> import csv
>>
>> csvfile= open('StudentListToSort.csv', newline='')
>> spamreader = csv.DictReader(csvfile,delimiter=',',quotechar='|')
>
> Are you sure that your input file uses | as a quote character and , as
> the field delimiter?
No I overlooked this
>
>
>> #open a file to write to l
Ok I used :
spamwriter.writerow({'user':email,'first':row['first'],'last':row['last'],
'password':row['password'] })
Seems to be almost finished thanks
> From: dux...@hotmail.com
> To: tutor@python.org
> Date: Mon, 23 Jun 2014 09:17:44 +
> Subject:
>
> On Mon, Jun 23, 2014 at 09:17:44AM +, Ian D wrote:
>
> > > for row in spamreader:
> > > if row['year'] == '40':
> > > email = row['user'] + '@email.com'
> > > output = [ row[fieldname] f
Hi
I have seen some examples that seem to use a tuple with a method called index()
The original code I was looking at had this sort of thing:
SENSORS = ('sensor1', 'sensor2')
pin_index = SENSORS.index("sensor1")
so the result is that pin_index the is equal to 0
I the
.
> To: tutor@python.org
> From: __pete...@web.de
> Date: Wed, 11 Mar 2015 16:35:09 +0100
> Subject: Re: [Tutor] Tuple indexing
>
> Ian D wrote:
>
>> Hi
>>
>>
>>
>> I have seen some examples that seem to use a tuple with a method called
>
Hi
I run a regex like this:
>pchars = re.compile('\x00\x00\x00') #with or without 'r' for raw
on a string like this:
>data = "['broadcast', 'd8on\x00\x00\x00\x11broadcast', 'd11on']"
>print "found pchars :",pchars.findall(data)
which returns:
>found pchars : ['\x00\x00\x00']
But if I tr
wildcard for the last byte as it
changes?
Thanks
> Date: Sat, 28 Mar 2015 20:21:09 -0400
> From: da...@davea.name
> To: tutor@python.org
> Subject: Re: [Tutor] escape character regex
>
> On 03/28/2015 03:37 PM, Ian D wrote:
>> H
t; Is there a way to match using some sort of wildcard for the last byte as it
> changes?
>
>
> Thanks
>
>
>> Date: Sat, 28 Mar 2015 20:21:09 -0400
>> From: da...@davea.name
>> To: tutor@python.org
>> Subject: Re:
Hi
I have a list that I am splitting into pairs of values. But the list is dynamic
in size. It could have 4 values or 6 or more.
I originally split the list into pairs, by using a new list and keep a pair in
the old list by just popping 2 values. But if the list is longer than 4 values.
I cann
7
> Date: Tue, 31 Mar 2015 10:30:04 -0400
> From: da...@davea.name
> To: tutor@python.org
> Subject: Re: [Tutor] Dynamic naming of lists
>
> On 03/31/2015 10:00 AM, Ian D wrote:
>> Hi
>>
>> I have a list that I am splitting
Ok Thanks a lot. And sadly not a typo, my bad logic overwriting values!
> To: tutor@python.org
> From: __pete...@web.de
> Date: Tue, 31 Mar 2015 17:50:01 +0200
> Subject: Re: [Tutor] Dynamic naming of lists
>
> Ian D wrote:
>
>&
52 matches
Mail list logo