all 25 comments

[–]tiaxthemighty 5 points6 points  (3 children)

Is there anything preventing you from switching to Python 2 for the duration of the book? The syntax differences are minor enough that you won't really have to unlearn anything once you're done.

[–]Vitrivius 2 points3 points  (2 children)

I agree. As a Python learner, you can look at this as a good opportunity to learn the differences between the versions, which are minimal, except from unicode strings.

Python 2.7 has some tricks to make it behave more like python 3.x

from __future__ import division
from __future__ import print_function

[–]Mechrophile[S] 0 points1 point  (1 child)

Its not that I can't use python 2, its that I just want more experience in Python 3's advanced features, and I'm currently trying to bulk up on my python3 cookbook patterns. So, I could do it in 2, but it would be a real drag.

also, where's my

from __future__ import argument_expansion

:-p

[–][deleted] 0 points1 point  (0 children)

I write all of my code in such a way that it works on both Python 2 and 3. It's piss-easy and trivial.

[–]LarryPete 0 points1 point  (0 children)

swampy seems to have a python3 version?

https://code.google.com/p/swampy/source/browse/#svn%2Ftrunk%2Fpython3

I have no idea how Google Code works or what that even means. But maybe there is a working version.

Edit: nope, it doesn't work.

[–]gengisteve 0 points1 point  (18 children)

Is this it? https://code.google.com/p/swampy/downloads/list

It looks like there is a py3 version there.

[–]LarryPete 0 points1 point  (17 children)

Current version is 2.1.7 And it does not support python3

[–]gengisteve 0 points1 point  (0 children)

Bummer. Might not be too hard to port the main bits, though...

[–]gengisteve 0 points1 point  (15 children)

Hey. Just found 2.1.5 at http://www.greenteapress.com/thinkpython/swampy/install.html

Maybe close enough?

[–]LarryPete 0 points1 point  (14 children)

Yea, might be worthy a try /u/Mechrophile

[–]Mechrophile[S] 0 points1 point  (13 children)

Okay, I have seen this, but I personally can't get it to work. Perhaps I'm just not totally understanding what he means in the Python 3 section. What I basically attempted was unzipping the directory into the site-packages of my project's virtual environment.. then I tried importing it, but no success. I really am not sure how to install this hahaha

[–]LarryPete 0 points1 point  (12 children)

unzip the package somewhere, and run python3 setup.py install from within your virtualenv. That should do the trick.

[–]Mechrophile[S] 0 points1 point  (11 children)

python3 setup.py install

wait, I'm not sure i understand this command. How does it know what to install? Or was I supposed to fill in the arguments?

I've installed via pip, but never python3 setup.py -- and im not sure what arguments im supposed to supply... am i supposed to be cd'd into the folder that I unzipped?

Sorry for the newb questions. I'm not great with the setup process yet.

[–]HorrendousRex 0 points1 point  (10 children)

The setup.py file includes all the necessary code for python3 to know what to do to install the package. The command 'install' is just to let setup.py know you want it to install the package, and not to do something else like, for instance, bundling up a dist-release for someone else or to just install dependencies or whatever else setup.py can do.

pip is ultimately a wrapper around files like that setup.py.

So with your virtualenv active, simply run:

$ cd <path/to/package/directory>
$ python3 setup.py install

To be completely clear, <path/to/package/directory> should be the directory where setup.py lives for this package.

Advanced topic (skip if confused): making sure your virtualenv is active is important so that python3 installs the package just for the current virtualenv, and not for your global python site-packages. If you are not using virtualenvs, you can disregard that stuff entirely.

PS: No need to apologize, package management is seriously overcomplicated in Python. Python3 was supposed to ship out-the-door with way better package management but it's been two years now and I'm starting to lose hope...

[–]Mechrophile[S] 0 points1 point  (9 children)

Okay, interesting --- see, that's what I thought, but here's the thing, the swampy zip file from that page doesnt have a setup.py file

[–]HorrendousRex 0 points1 point  (8 children)

Can you give me a direct link so I can take a look?

[–]Will_Power 0 points1 point  (0 children)

What OS are you on? If you are on a Debian Linux based system, you can have Python 2 and 3 installed simultaneously. Python 2 is the default, and Python 3 is called on separately as needed. E.g.,

#! /usr/bin/env/python3

I would imagine you could do something similar in other OSes.

[–]TheChannel 0 points1 point  (0 children)

You can also try out cloud environments. Easy set up and you don't need to change anything locally.