Re: [Tutor] raise exception works as planned in program but not when imported into testing module

2015-04-30 Thread Jim Mooney Py3.4.3winXP
Oops, my mistake. Ignore dumb remark below.  I was thinking of the try -
except in the main loop, but since I only tested the parse function, I
never used that. I need to look a bit harder and find this stuff Before I
post ;')

Jim

On 29 April 2015 at 23:04, Jim Mooney Py3.4.3winXP  wrote:

>
> I think I meant something like this. An exception in a function is caught
> by the caller. I imported the program that did this into the test program,
> expecting the exception to still be caught when the parse_string was
> called, by the try except else block in the mainroutine of the imported
> program..
>
> def excepter():
> raise ValueError
>
> try:
> excepter()
> except ValueError:
> print("Exception caught after function call")
>
> REPL
> >>>
> Exception caught after function call
>




-- 
Jim

"What a rotten, failed experiment. I'll start over. Maybe dogs instead of
monkeys this time." --God
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Newbie problems

2015-04-30 Thread Jag Sherrington
Can anyone please tell me what I am doing wrong?As this code I have for the 
Roulette Wheel colours exercise, won't work. number = int(input('Enter a number 
between 0 and 36: '))green_number = (0) red_number = (1, 3, 5, 7, 9, 12, 14, 
16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36) black_number = (2, 4, 6, 8, 10, 11, 
13, 15, 17, 20, 22, 24, 26, 28, 34, 29, 31, 33, 35)
if number == green_number:    print('Number is Green')    elif number == 
red_number:    print('Number is Red')    elif number == black_number:        
print('Number is Black')
Thank you for any help, Jag

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread Laura Creighton
In a message of Wed, 29 Apr 2015 23:28:59 -0500, boB Stepp writes:

>The main danger as I see it is that if I am not careful, then the code
>on the dev environment could diverge from the state of code on my
>Windows PC, i.e., I forgot to do the scp part. But when I am actively
>working on a section of code I always insert a few print statements
>(Py 2.4!) to verify I am getting what I should when I test it
>out--even if I don't have an actual problem yet. And so far this has
>immediately revealed those few instances so far when I forgot to save
>to the dev machine (Usually when someone has interrupted my workflow,
>a near constant occurrence at work.).

If you can get git running on your solaris development machine, you can
get out of the 'manually copying files' business. You can just ask git
for an up to date version of all your code, all your tests, all your
documentation -- all the files. :)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] if/then statement and sql count rows

2015-04-30 Thread Spencer For Friends
Hi All,

I'm attempting to perform an if then statement based on the results of a
sql count rows query. The query is returning the proper values however the
if/then statement seems to be ignoring the returned value of the sql
statement.

Here is my code.

import sqlite3

# Define SQL statement to select all Data from Column Name
sql = "SELECT Count(*) FROM arbtable WHERE Name = ?"

book_name = 'Winged Coat'

class PriceCheck(object):
def __init__(self, db):
self.conn = sqlite3.connect(db)
self.c = self.conn.cursor()


def query(self, arg, cardname):
self.c.execute(arg, cardname)
return self.c

def __del__(self):
self.conn.close()

def display():
#Connect To DB and Get Price of Matched book.
getbookprice = PriceCheck("arbbase.sqlite")
for row in getbookprice.query(sql, ([book_name])):
if row == 0:
print 'no row was found'
else:
   print 'Yep its there!'
print row



display()

The program here is that my result, as evidenced by "print row" at the
bottom of the code is 0. Since it is zero according to my if statement it
should print 'no row was found', but instead it prints the else statement
value of 'yes its there!'

I've researched extensively and think that possibly the fetchone statement
is what I need, but I can't seem to figure out how to properly apply this
to my code to test it.

Any help would be highly appreciated.

Thank you kindly

Sour Jack
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 2.4 (was comparison operators)

2015-04-30 Thread Laura Creighton
Python 2.4 is really old, right now.  OpenCSW has 2.6.9
http://www.opencsw.org/package/python/

Any chance you could use that?

Laura

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: circular movement in pygame

2015-04-30 Thread diliup gabadamudalige
Thanks all for the very informative responses especially to Alan for being
descriptive.

I am now going to make my movement linear and move away from my current
circular one.

I hope a little bit of fun and "Thank you" emails fall into the order of
the day..

:)

On Thu, Apr 30, 2015 at 9:13 AM, Dave Angel  wrote:

> On 04/29/2015 02:37 PM, diliup gabadamudalige wrote:
>
>> I do not understand how Alan does not get the code that is in this thread.
>>
>
> There are at least 3 ways of posting to "this thread":
>A) email
>B) newsgroup
>C) googlegroups
>
> and at least 5 ways of looking at "this thread"
>A) email
>B) email digest
>C) newsgroup
>D) googlegroups
>E) various archives
>
> To get messages from one region to another involves going through a
> gateway, and most of them damage some of the messages going through.  To
> minimize the likelihood that what looks good on your screen will be missing
> or different on mine or on Alan's, follow a few rules:
>
>1) avoid html
>2) avoid attachments
>
> There are others, but those seem to be the biggies.
>
> Many other guidelines will help readability and consistency, like not
> top-posting, using proper quoting and attribution, giving enough
> information but not too much, specifying the whole environment in the FIRST
> message of a thread, etc.
>
> --
> DaveA
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] subprocess.Popen(..., cwd) and UNC paths

2015-04-30 Thread Alan Gauld

On 30/04/15 01:48, eryksun wrote:

> Actually cmd.exe is fine with UNC paths.
cmd.exe cannot use a UNC path as the current directory.

Oops, my mistake. I got my POSIX and UNC mixed up.
I was thinking about forward slashes etc not network names.

Apologies for not reading the message properly.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread Alan Gauld

On 30/04/15 05:28, boB Stepp wrote:


That is what I have implemented as of today. I installed Git on my
Windows PC where I have been doing my actual coding


This is off topic but due to your peculiar restrictions might
be useful so I thought I'd bring it up.

Do you have Cygwin installed on your PC?

Its a Unix-like user environment that runs on Windows including
Python and the other tools (including X windows). It makes
writing and testing code for a Unix box on a Windows box
very much easier.

If you haven't investigated it before I strongly recommend it.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Newbie problems

2015-04-30 Thread Dave Angel

On 04/29/2015 11:58 PM, Jag Sherrington wrote:

Can anyone please tell me what I am doing wrong?As this code I have for the 
Roulette Wheel colours exercise, won't work. number = int(input('Enter a number 
between 0 and 36: '))green_number = (0) red_number = (1, 3, 5, 7, 9, 12, 14, 
16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36) black_number = (2, 4, 6, 8, 10, 11, 
13, 15, 17, 20, 22, 24, 26, 28, 34, 29, 31, 33, 35)
if number == green_number:print('Number is Green')elif number == 
red_number:print('Number is Red')elif number == black_number:
print('Number is Black')
Thank you for any help, Jag



Please post your code the way you're going to run it, like one statement 
per line, indented as required, etc.


Your problem is you're comparing an int (number) to a list (green_number 
or red_number or black_number).  They'll never be equal so it won't 
print anything.


presumably you don't want to know if the number is equal to the list, 
but whether it's in the list.  The "in" operator will tell you that.


Something like:
if number in green_numbers:

(I changed it to plural, so it'd be more obvious that it's not a single 
value, but a list of them.  Little things like that can make errors much 
easier to spot.)



--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Newbie problems

2015-04-30 Thread Alan Gauld

On 30/04/15 04:58, Jag Sherrington wrote:

Can anyone please tell me what I am doing wrong?As this code I have for the 
Roulette Wheel colours exercise, won't work. number = int(input('Enter a number 
between 0 and 36: '))green_number = (0) red_number = (1, 3, 5, 7, 9, 12, 14, 
16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36) black_number = (2, 4, 6, 8, 10, 11, 
13, 15, 17, 20, 22, 24, 26, 28, 34, 29, 31, 33, 35)
if number == green_number:print('Number is Green')elif number == 
red_number:print('Number is Red')elif number == black_number:
print('Number is Black')
Thank you for any help, Jag


The first problem is that you are posting in HTML which is losing
all the code formatting, making it hard to read.

Also you don't actually tell us what doesn't work. If you get an
error message post it. If you get different results to what you
expect tell us what you expect and what you got.

For now I'll take a guess below...

number = int(input('Enter a number between 0 and 36: '))
green_number = (0)
red_number = (1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 
34, 36)
black_number = (2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 34, 
29, 31, 33, 35)

if number == green_number:
print('Number is Green')
elif number == red_number:
print('Number is Red')
elif number == black_number:
print('Number is Black')

Note that you are testing the number for equality, which means it
must be exactly the same value.

But your red_number and black_number are both tuples of several
numbers so a single number will never equal a sequence of numbers.
You should use the 'in' test instead of equals.

Like

if number in red_number:


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] if/then statement and sql count rows

2015-04-30 Thread Alan Gauld

On 30/04/15 03:59, Spencer For Friends wrote:


 class PriceCheck(object):
 def __init__(self, db):
 self.conn = sqlite3.connect(db)
 self.c = self.conn.cursor()


 def query(self, arg, cardname):
 self.c.execute(arg, cardname)
 return self.c


You are returning the cursor object here.
That's probably not what the user of your code wants,
it would be better to return the actual result.
You can get that using fetchone() or fetchall()
Since count() can only return one value fetchone()
would be best here.

return self.c.fetchone()


 def __del__(self):
 self.conn.close()

 def display():
 #Connect To DB and Get Price of Matched book.
 getbookprice = PriceCheck("arbbase.sqlite")
 for row in getbookprice.query(sql, ([book_name])):


Insert a debug statement here:

print type(row), ':', row

And see if what you get is what you expect.


 if row == 0:
 print 'no row was found'
 else:
print 'Yep its there!'
 print row


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to use Git from Windows PC for files on Solaris machine where Git cannot be installed?

2015-04-30 Thread boB Stepp
On Wed, Apr 29, 2015 at 11:38 PM, Dave Angel  wrote:
> On 04/30/2015 12:28 AM, boB Stepp wrote:
>>
>> The main danger as I see it is that if I am not careful, then the code
>> on the dev environment could diverge from the state of code on my
>> Windows PC, i.e., I forgot to do the scp part. But when I am actively
>> working on a section of code I always insert a few print statements
>> (Py 2.4!) to verify I am getting what I should when I test it
>> out--even if I don't have an actual problem yet. And so far this has
>> immediately revealed those few instances so far when I forgot to save
>> to the dev machine (Usually when someone has interrupted my workflow,
>> a near constant occurrence at work.).
>>
>>
>
> Add an automatic file copy to the save-key definition in your editor. Then
> whenever you save the file locally, you'll also be copying it to the master
> location.

Many, many thanks, Dave! This was easily done in and will match my
local and remote file saves exactly as they need to be. It did not
even occur to me that this feature existed. Heavy, sigh! I have so
many blind spots...


-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Roel Schroeven

Alan Gauld schreef op 2015-04-30 00:51:

> ...


Trying to visually scan for _ or even __ is hard. Also different
fonts make _ and __ hard to distinguish.


> ...

But they will be. Almost for certain. It's human nature and the nature 
of code maintenance. If it's there somebody will find a use for it. The 
fact that 5 or 10 years earlier the author didn't intend for it to be 
used is immaterial.


Summarizing a bit, I think you make two main points (please correct me 
if I'm wrong):


[1] Visually scanning for _ or __ is hard, and _ are __ hard to 
distinguish from each other.


Personally, I find it easy to scan for them, but I think I can see whee 
you're coming from. Python tends to prefer words and tends to dislike 
symbols compared to e.g. C, C++, and certainly Perl. One could argue 
that using _ or __ goes against that, though to me it's not a problem. 
We're still very far from Perl's line noise.
It's true that _ and __ can be difficult to be distinguished from each 
other, but that's also not a problem to me, since I don't care about 
their values.



[2] Inevitably, sooner or later someone somewhere will start using _ or 
__ despite the fact that by convention they should not be used.


I have to admit that I have no experience programming in larger teams, 
and was blissfully unaware of the problems you describe. I think I can 
see how it might be better to avoid __ rather than try to enforce good 
coding discipline.



I still feel __ to be valuable, but I can see now where your dislike for 
it is coming from. Thank you for your insights!



Best regards,
Roel

--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Dave Angel

On 04/30/2015 03:22 PM, Roel Schroeven wrote:

Alan Gauld schreef op 2015-04-30 00:51:

 > ...


Trying to visually scan for _ or even __ is hard. Also different
fonts make _ and __ hard to distinguish.


 > ...


But they will be. Almost for certain. It's human nature and the nature
of code maintenance. If it's there somebody will find a use for it.
The fact that 5 or 10 years earlier the author didn't intend for it to
be used is immaterial.


Summarizing a bit, I think you make two main points (please correct me
if I'm wrong):

[1] Visually scanning for _ or __ is hard, and _ are __ hard to
distinguish from each other.

Personally, I find it easy to scan for them, but I think I can see whee
you're coming from. Python tends to prefer words and tends to dislike
symbols compared to e.g. C, C++, and certainly Perl. One could argue
that using _ or __ goes against that, though to me it's not a problem.
We're still very far from Perl's line noise.
It's true that _ and __ can be difficult to be distinguished from each
other, but that's also not a problem to me, since I don't care about
their values.


[2] Inevitably, sooner or later someone somewhere will start using _ or
__ despite the fact that by convention they should not be used.

I have to admit that I have no experience programming in larger teams,
and was blissfully unaware of the problems you describe. I think I can
see how it might be better to avoid __ rather than try to enforce good
coding discipline.


I still feel __ to be valuable, but I can see now where your dislike for
it is coming from. Thank you for your insights!



Well, are you aware that _ has a meaning in the debugger?  It holds the 
last value of an expression that wasn't assigned to a variable.  or 
something like that.


So even if you don't have any coworkers, you might trip on someone 
else's assumptions.


To see what I'm talking about:

>>> 3*4
12
>>> print(_)
12




Best regards,
Roel




--
DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Roel Schroeven

Dave Angel schreef op 2015-04-30 21:33:
Well, are you aware that _ has a meaning in the debugger?  It holds the 
last value of an expression that wasn't assigned to a variable.  or 
something like that.


Yes, I know the meaning of _ in Python's interactive mode. It's 
something I sometimes use for convenience, but never really rely on. To 
me interactive mode is for trying out simple things, not for serious stuff.


Anyway, as explained in this style guide it's better to use __ anyway 
instead of _:


http://docs.python-guide.org/en/latest/writing/style/#create-an-ignored-variable


--
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Alan Gauld

On 30/04/15 20:22, Roel Schroeven wrote:

Alan Gauld schreef op 2015-04-30 00:51:



Summarizing a bit, I think you make two main points (please correct me
if I'm wrong):


Your quite correct.

I'm probably a bit paranoid but as I said I spent a
significant bit of my production-programming career
(about 40%) on maintenance projects and I've seen the
horrors that come from uninitialised variables, misused
names etc etc. And any kind of meaningless symbiol
(even if the meaning is not needed at the time).
And in a maintenance team where you are targetted
to fix, say, 4 bugs per day, a "horror" is anything
that adds more than say 15-20 minutes to the process!


[1] Visually scanning for _ or __ is hard, and _ are __ hard to
distinguish from each other.

Personally, I find it easy to scan for them, but I think I can see whee
you're coming from. Python tends to prefer words and tends to dislike
symbols


Yes but worse in this cae is tat Python uses __ for special
purposes so if there is a __ near to a variable name the reader
is likely to assume its just a pre-pended dunder marker rather
than a separate name. It also makes searching for dunders harder
since there are likely to be quite a few in the code already.
(yes you can create a regex search but making it reliable
is quite tricky.)


[2] Inevitably, sooner or later someone somewhere will start using _ or
__ despite the fact that by convention they should not be used.

I have to admit that I have no experience programming in larger teams,
and was blissfully unaware of the problems you describe.


Again my experience is not typical of the tutor forum, but
some tutor readers may go on to bigger things and bad habits
once learned become permanent...

My smallest project team was 7  programmers producing 80,000
lines of code. Next smallest 18, producing 250,000.
Most of my projects have had over 100 programmers and several
million LOC (usually C++ or COBOL)

One project had over 1000 programmers and produced 60 million
LOC using 7(?) different programming languages. (I ran one of
the maintenance teams of ~10 coders all fresh from  uni')

Like I say I get paranoid about some things :-)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Good Taste Question: Using SQLite3 in Python

2015-04-30 Thread Laura Creighton
The fact that _ and __ are intended as throw away values is only clear
to people who have read a particular doc about coding styles.  If you
haven't read the doc, you don't know what is going on.  I name my
throw away variables junk, and if there are lots of them, for instance
when I am reading from a list of tuples, but only care about the fourth
item in each tuple, its 'junk1, junk2, junk3 ...'

So far I have yet to meet somebody who wasn't immediately aware that
I did not care about those values.

Laura

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Ancient Python versions (was: Is there a way to store and later use comparison operators (<, <=, =, >=, >) ?)

2015-04-30 Thread boB Stepp
On Thu, Apr 30, 2015 at 12:15 AM, Ben Finney  wrote:
> boB Stepp  writes:
>
>> One problem I have with searching the Python documentation is this:
>> https://docs.python.org/release/2.4.4/lib/lib.html
>
> If you actually need to read the documentation specifically for a Python
> version that has not been supported since 2008, then I agree that is a
> problem.

I'm pretty much stuck with these relics of Pythons past.

> The documentation has improved since then. If you want newer-looking
> documentation, maybe you should not expect it from a Python released
> nearlt a decade ago?

No, I am not looking for fancy aesthetics. I am looking for
intelligent use of whitespace, so that everything does not run
together into a nearly indistinguishable blob. Bold main section
headings would be nice as well. All of this has been possible forever
and evermore. Readability counts! ~(:>)

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Ancient Python versions

2015-04-30 Thread Ben Finney
boB Stepp  writes:

> On Thu, Apr 30, 2015 at 12:15 AM, Ben Finney  
> wrote:
> > If you actually need to read the documentation specifically for a
> > Python version that has not been supported since 2008, then I agree
> > that is a problem.
>
> I'm pretty much stuck with these relics of Pythons past.

Then you are, unfortunately, stuck with the documentation for that
version. It will not be updated any more, because support for that
ancient version has ended.

> > The documentation has improved since then. If you want newer-looking
> > documentation, maybe you should not expect it from a Python released
> > nearlt a decade ago?
>
> No, I am not looking for fancy aesthetics. I am looking for
> intelligent use of whitespace, so that everything does not run
> together into a nearly indistinguishable blob. Bold main section
> headings would be nice as well. All of this has been possible forever
> and evermore. Readability counts! ~(:>)

So you might like to borrow the Python time machine and complain to the
people of the mid-2000s.

Complaining about it today, when the currently-maintained documentation
does not have these problems, is futile.

-- 
 \ “Quidquid latine dictum sit, altum viditur.”  (“Whatever is |
  `\  said in Latin, sounds profound.”) —anonymous |
_o__)  |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Questions (and initial responses) on using version control: Why cannot I push my single (master) branch to origin without an error occurring?

2015-04-30 Thread boB Stepp
I created my remote repository on, say my C-drive, with "git init". I
then copied and pasted a file to that location and put it under
version control with "git add filename.py". Next I went to my E-drive,
which is where I intend to be my working directories. After setting up
a similar directory structure (/Projects/), I typed "git clone
C:/Projects/project_name" and the desired result appeared on E:
E:/Projects/project_name/filename.py. All seemed well with the world!

Now I made some edits to filename.py in my working directory,
added/committed and then attempted to push to the remote repository
and got this:

boB Stepp@DREAMMACHINE1 /e/Projects/project_name (master)
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to

remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into

remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some

remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set

remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To c:/Projects/project_name
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'c:/Projects/project_name'

I did the usual Google search. What I found recommended I cd to the
remote repository, create a new temporary branch, and then checkout
that branch. Then go back to my working directory and then push to the
remote repository. This works. Problem: I don't understand why what I
was originally doing does not allow me to do a push with errors. Would
someone please elucidate?

And since I am obviously not in the know here, my attempted workflow
must be flawed. Would someone point out the "proper" way to initiate a
new project under Git version control?

Thanks!

boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 2.4 (was comparison operators)

2015-04-30 Thread boB Stepp
On Thu, Apr 30, 2015 at 1:02 AM, Laura Creighton  wrote:
> Python 2.4 is really old, right now.  OpenCSW has 2.6.9
> http://www.opencsw.org/package/python/
>
> Any chance you could use that?

Laura, I may just attempt this on the dev machine. I have mentioned
before that the production environment is running Python 2.6.x (I
think it is 2.6.6, but don't remember for certain.). Surely updating
Python on the dev to one very near the prod env is an improvement? And
if I am going to do that, I might as well install Git. And I will
probably throw in gVim, too. I have been pondering everyone's comments
to date, and it seems to me that I should be doing all of my
development on the development environment machine and it is thus
justifiable to add the tools I need to effectively do this (Again,
thanks for your thoughts, Cameron!). This seems more *sane*! Plus it
will save me tons of time.

Even though the link you gave was for a package add, I just *know*
there will be missing dependencies. Guess I will have to learn how to
resolve all the issues that come up. Should be fun!

Thanks, Laura!

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Questions (and initial responses) on using version control: Why cannot I push my single (master) branch to origin without an error occurring?

2015-04-30 Thread Alex Kleider

On 2015-04-30 20:39, boB Stepp wrote:

I created my remote repository on, say my C-drive, with "git init". I
then copied and pasted a file to that location and put it under
version control with "git add filename.py". Next I went to my E-drive,
which is where I intend to be my working directories. After setting up
a similar directory structure (/Projects/), I typed "git clone
C:/Projects/project_name" and the desired result appeared on E:
E:/Projects/project_name/filename.py. All seemed well with the world!

Now I made some edits to filename.py in my working directory,
added/committed and then attempted to push to the remote repository
and got this:


I would suggest the following work flow to set up two parallel 
repositories:


cd 
git init

git add 
git commit

cd 
git clone 
# the above command brings in a copy of all that was committed in the 
first repo.


Once this is done, I believe your subsequent commits can be pushed 
without the errors.




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor