thegooglecodearchive / sfepy

Automatically exported from code.google.com/p/sfepy
0 stars 0 forks source link

Test for "basestring" instead of "str" #160

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please replace occurences of isinstance(something, str) by 
isinstance(something, basestring).  This is an easy change, and it makes it 
more convenient to use SfePy with

from __future__ import unicode_literals

Otherwise, you have to say e.g.

mesh = Mesh.from_file(b'rectangle_tri.mesh')

(The "b" would become superfluous.)

Original issue reported on code.google.com by torsten....@gmail.com on 20 Dec 2011 at 10:26

GoogleCodeExporter commented 9 years ago
Looks like a good thing to do, thanks for creating the issue.

Do you have other ideas to python 3 compatibility?

Original comment by robert.c...@gmail.com on 20 Dec 2011 at 1:14

GoogleCodeExporter commented 9 years ago
Import as many future statemens as feasible ("division", "absolute_imports", 
"unicode_literals", "print_function") in every module.  "division" and 
"absolute_imports" are especially interesting in my opinion.

Replace % with .format().

By the way, for Python 3, the "basestring" has got to be re-changed to "str".  
But this will be done by 2to3 automatically.

Original comment by torsten....@gmail.com on 20 Dec 2011 at 1:27

GoogleCodeExporter commented 9 years ago
I would like to have a way that would work both for python 2 with "from 
__future__ import unicode_literals" and python 3. Would using types.StringType 
help?

I do not have a working python 3 installation yet, still using 2.6.6... I can 
try 2.7. and use -3 flag to simulate it, right?

I will create a new issue for python 3 porting to discuss this.

Original comment by robert.c...@gmail.com on 21 Dec 2011 at 11:11

GoogleCodeExporter commented 9 years ago
You can start the modules with

try:
    basestring
except:
    basestring = str

Original comment by torsten....@gmail.com on 21 Dec 2011 at 12:02

GoogleCodeExporter commented 9 years ago
Could you test using "git clone git://github.com/rc/sfepy.git"?

Original comment by robert.c...@gmail.com on 21 Dec 2011 at 12:38

GoogleCodeExporter commented 9 years ago
Sorry, not this year.  I don't use Git but the plain release.  I'll look into 
it on the first days of the new year.

Original comment by torsten....@gmail.com on 21 Dec 2011 at 3:19

GoogleCodeExporter commented 9 years ago
Ok, thanks! As a sidenote: using git is not that difficult, and you get fresh 
fixes easily, see [1].

[1] http://docs.sfepy.org/doc-devel/dev/gitwash/index.html#using-git

Original comment by robert.c...@gmail.com on 22 Dec 2011 at 11:14

GoogleCodeExporter commented 9 years ago
Yes, it has worked.  No "b" was necessary anymore.  Thank you!

Original comment by torsten....@gmail.com on 2 Jan 2012 at 4:16

GoogleCodeExporter commented 9 years ago
Thanks for verifying, let's close this.

Original comment by robert.c...@gmail.com on 2 Jan 2012 at 4:18

GoogleCodeExporter commented 9 years ago
Migrated to http://github.com/sfepy/sfepy/issues/162

Original comment by robert.c...@gmail.com on 30 Jan 2012 at 10:27