Re: Import Doesn't Import
On 16/10/2014 01:44, ryguy7272 wrote: If you carry on using this approach and you continue using the buggy google groups interface you're unlikely to make many friends. May I suggest that before posting you spend a few minutes doing some research as Python has been in use for 22 years so your questions have been answered many times before. Either this is the most brilliant thing ever invented, or it's the biggest piece of shit ever invented. I just can't tell. All I know for sure, is that it doesn't do ANYTHING that I tell it to do. A bad workman always blames his tools. If there is another way of running Python code, like using Visual Studio, or a text file, or some such thing, let me know, and I'll do it. It seems like you should use Python to run Python, but my Python doesn't do anything at all. Yesterday I uninstalled Python 2.7, because that wouldn't do anything either. I'm just about ready to uninstall 3.4. https://docs.python.org/3/using/windows.html https://docs.python.org/3/using/windows.html#launcher -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Question About Running Python code
On 15/10/2014 23:50, ryguy7272 wrote: The error that I get is this. 'invalid syntax' The second single quote in this line is highlighted pink. print 'Downloading data from Yahoo for %s sector' % sector This is a script written for Python 2.*, but you say you are using Python 3.4. In Python 3, "print" is a function, not a statement, so you need to translate this to print('Downloading data from Yahoo for %s sector' % sector) -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
- Original Message - > From: Rustom Mody > To: python-list@python.org > Cc: > Sent: Monday, October 13, 2014 10:00 AM > Subject: Re: what is the easiest way to install multiple Python versions? > > On Monday, October 13, 2014 1:24:27 PM UTC+5:30, Chris Angelico wrote: >> On Mon, Oct 13, 2014 at 1:31 PM, Rustom Mody wrote: >> > Hearing a bit about docker nowadays. >> > Here's why its supposedly better than a VM: >> > https://www.docker.com/whatisdocker/ >> > Downsides?? No idea! > >> One obvious downside is that it doesn't allow guests to modify the OS >> at all. A VM gives you an entire OS, so you can use and manipulate >> anything. If you don't *need* all that flexibility, then a VM is >> paying an unnecessary cost, ergo Docker will have no downside. > > Was talking of more pragmatic downsides eg "Does it really work?" :-) > [Docker is still quite new] I have not used Docker before but I did look into it. Reason why I chose I full VM (Virtualbox in conjunction with Jenkins CI) is that I also needed to test Windows platforms. AFAIK, the Docker guest systems *must* be unix, possibly only Linux. A big plus of Docker is that the guest systems share resources, so it is a lot lighter to run multiple guest machines. I did hear that nowadays it is possible to use a Windows *host* system. -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
- Original Message - > From: Chris Angelico > To: > Cc: Python > Sent: Sunday, October 12, 2014 4:20 PM > Subject: Re: what is the easiest way to install multiple Python versions? > > On Mon, Oct 13, 2014 at 12:33 AM, Albert-Jan Roskam > > wrote: >> *) Make altinstall >> sudo apt-get install libsqlite3-dev libbz2-dev libgdbm-dev libncurses5-dev > tk-dev zlib1g-dev >> wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz >> tar -zxvf Python-2.6.8.tgz >> cd Python-2.6.8/ >> ./configure --prefix=/usr/local >> make # see 'failed stuff' below >> sudo make altinstall >> mkvirtualenv -p /usr/local/bin/python2.6 python26 # ImportError: No module > named zlib >> >> >> # Failed stuff >> Failed to find the necessary bits to build these modules: >> _bsddb_curses_curses_panel >> _hashlib _sqlite3 _ssl >> bsddb185 bz2dbm >> dlgdbm imageop >> linuxaudiodev ossaudiodevreadline >> sunaudiodevzlib > > Generally, this is the method I would recommend. For a start, run this: > > sudo apt-get build-dep python Aha, useful tip. But won't this (re)build the dependencies of the default python version? Or should I do sudo apt-get build-dep python-2.6? > This is in place of your explicit "apt-get install" command; Debian > keeps track of the dev packages needed to rebuild a given program, and > will go fetch them for you. > > After that, just look at exactly what packages you're still lacking. > You may well find that you don't have all the dependencies for all > Python modules, as some of them might not be included in a basic > "apt-get install python" installation; the solution is a bit more > "apt-get build-dep" work, or some manual hunting down of dev packages > (which may well be easier in some situations). > > But what version of Debian are you after, and why are you trying to > build a 2.6.8 from source? On Debian Wheezy, getting hold of Python > 2.6 should be as easy as: > > $ sudo apt-get install python2.6 > > I believe Squeeze ships 2.6 as its standard system Python, so it's > even easier. Are you on the unreleased Jessie? And why do you even > need 2.6 as opposed to 2.7? I am on Debian 7.6, Wheezy (Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux). Wow, so it is really this simple? This was actually the first option I considered, but I was so paranoid to ruin my default Python version. Reason why I need Python 2.6? The script needs to run on a server that turned out to have Python 2.6. It is beyond my power to upgrade the Python version. Thanks all! -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
- Original Message - > From: Gayathri J > To: Albert-Jan Roskam > Cc: Python > Sent: Sunday, October 12, 2014 6:15 PM > Subject: Re: what is the easiest way to install multiple Python versions? > > I have been using Anaconda's (Continnum) conda installation for system > installation (python 2.7) and for python 3 > > conda lets us maintain diferent environments with different python and > different combinations of other packages like numpy etc... > > sure not to disappoint! Thanks! Yeah, Anaconda seams very promising. I am also curious about numba, which is part of conda IIRC. Curious how it compares to Cython. Awesome that it's possible to add a numba decorator to speed up an arbitrary function. -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
On Thu, Oct 16, 2014 at 7:42 PM, Albert-Jan Roskam wrote: > >> From: Chris Angelico >> Generally, this is the method I would recommend. For a start, run this: >> >> sudo apt-get build-dep python > > Aha, useful tip. But won't this (re)build the dependencies of the default > python version? > Or should I do sudo apt-get build-dep python-2.6? It would install (not usually build) all the dependencies of the default Python, yes; but if you're compiling from source, that's usually going to be fairly close. For instance, if you want to build Python 3.5 from Mercurial, the easiest way to get started would be "apt-get build-dep python3"; that might not get absolutely everything, but it's sure going to be close. Python's dependencies don't change hugely between minor versions. >> But what version of Debian are you after, and why are you trying to >> build a 2.6.8 from source? On Debian Wheezy, getting hold of Python >> 2.6 should be as easy as: >> >> $ sudo apt-get install python2.6 > > I am on Debian 7.6, Wheezy (Linux debian 3.2.0-4-amd64 #1 SMP Debian > 3.2.60-1+deb7u3 x86_64 GNU/Linux). Wow, so it is really this simple? This was > actually the first option I considered, but I was so paranoid to ruin my > default Python version. > I'm fairly sure - though you could easily confirm - that installing the python2.6 package won't fiddle with the name "python", nor the name "python2", but will simply add another name "python2.6". I have it installed on my main Wheezy system, and that's how it is. Not sure if there's a way to tweak that with update-alternatives or anything. > Reason why I need Python 2.6? The script needs to run on a server that turned > out to have Python 2.6. It is beyond my power to upgrade the Python version. > > Thanks all! Fair enough. The differences between 2.6 and 2.7 aren't great, though, so you may well be able to port it trivially. But in any case, so long as you have Wheezy, you should be able to run 2.6 the easy way. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
- Original Message - > From: Terry Reedy > To: python-list@python.org > Cc: > Sent: Monday, October 13, 2014 2:54 AM > Subject: Re: what is the easiest way to install multiple Python versions? > > On 10/12/2014 9:33 AM, Albert-Jan Roskam wrote: > > >> A few days ago I needed to check whether some Python code ran with >> Python 2.6. What is the easiest way to install another Python version >> along side the default Python version? My own computer is Debian >> Linux 64 bit, but a platform-independent solution would be best. > > Installation is platform dependent. On Windows, the answer would simply > be 'get the PSF x.y installer and run it'. Thank you. Yes, for Windows it is easy. I was just scared that I would accidentally replace my default Python version 2.7 with 2.6 --and ruin my system. -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a counter
> > Python3: >print(counter, end='\r') > > Gary Herron > > Thanks, that is what I was looking up - \r carriage return without linefeed. Thanks again! Shiva -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
- Original Message - > From: Chris Angelico > To: > Cc: Python > Sent: Thursday, October 16, 2014 10:48 AM > Subject: Re: what is the easiest way to install multiple Python versions? > > On Thu, Oct 16, 2014 at 7:42 PM, Albert-Jan Roskam > The differences between 2.6 and 2.7 aren't great, though, > so you may well be able to port it trivially. But in any case, so long > as you have Wheezy, you should be able to run 2.6 the easy way. Most things were indeed easy to solve. But this one surprised me. With Python 2.6, I need to outcomment the 'lambda' line. The error is what I get in Python 2.6. It does not matter if I do u"\n".join(het_logboek[i:]). I don't use latin-1 anywhere in my program. I need to convert unicode to bytes in Python 2.6, or else it chokes in the smart quote. import codecs import os import time def print_log_van_vandaag(logbestand): """Print today's log. The Cron Daemon will mail this""" vandaag = time.strftime("%Y-%m-%d") with codecs.open(logbestand, encoding="utf-8") as logboek: het_logboek = logboek.readlines() #het_logboek = map(lambda x: x.encode("utf-8"), het_logboek) # bug in Python 2.6? for i, regel in enumerate(het_logboek): if regel.startswith(vandaag): print os.linesep.join(het_logboek[i:]) break Traceback (most recent call last): File "mailer.py", line 410, in print_log_van_vandaag("mailer.log") File "mailer.py", line 399, in print_log_van_vandaag print os.linesep.join(het_logboek[i:]) UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2018' in position 10214: ordinal not in range(256) -- https://mail.python.org/mailman/listinfo/python-list
python3 on mac-mavericks (was trying idle)
On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: > One may have to install activestate tkc/tk on mac, depending on osx > version. This page has details: > https://www.python.org/download/mac/tcltk Ok Ive some more information: The people in the audience using macs are using mavericks Whats the best way to setup python3 for that? I remember seeing some two different repos (if that what they are called in mac-land) for python. With some different tradeoffs which I dont understand. Another related question for mac-python usage: I asked one of the mac-users: Please start your default python in a shell and tell me what version it is. Answer: Mac has no shell. I find this hard to believe. Is a shell called something else in mac-maverick?? Where/how to find it? -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a counter
On Wednesday, 15 October 2014 19:39:43 UTC+1, Shiva wrote: > I am trying to search a string through files in a directory - however while > Python script works on it and writes a log - I want to present the user with > count of number of strings found. So it should increment for each string > found. You may ignore the following if you are just starting out on your Python learning odyssey but if you're past the early stages and looking to try something different then read on. When you looked through the other answers and found a solution you're happy with that does not use the standard library you can look through the documentation and find a stdlib (https://docs.python.org/2.7/library/index.html) provided way that may be slightly more elegant for counting strings. Something like the following :: >>> from collections import defaultdict >>> counter = defaultdict(int) >>> counter['string1'] += 1 >>> counter['string2'] += 1 >>> counter['string1'] += 1 >>> print('Count string1={string1}, string2={string2}'.format(**counter), end='\r') Count string1=2, string2=1 https://docs.python.org/3/library/collections.html#collections.defaultdict In the above code defaultdict is like a dictionary but if a key is not found then it uses the `int` factory parameter to add a value that is an integer with a value of 0 (which is what executing ``int()`` returns if you do it in the interactive Python prompt) for the dictionary key you're trying to access. or :: >>> from collections import Counter >>> counter = Counter() >>> s = 'string1 string2 string1' >>> s.split() ['string1', 'string2', 'string1'] >>> counter.update(s.split()) >>> print('Count string1={string1}, string2={string2}'.format(**counter), end='\r') Count string1=2, string2=1 https://docs.python.org/2.7/library/collections.html#collections.Counter -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On 2014-10-16 14:29, Rustom Mody wrote: On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: One may have to install activestate tkc/tk on mac, depending on osx version. This page has details: https://www.python.org/download/mac/tcltk Ok Ive some more information: The people in the audience using macs are using mavericks Whats the best way to setup python3 for that? I remember seeing some two different repos (if that what they are called in mac-land) for python. With some different tradeoffs which I dont understand. Another related question for mac-python usage: I asked one of the mac-users: Please start your default python in a shell and tell me what version it is. Answer: Mac has no shell. I find this hard to believe. Is a shell called something else in mac-maverick?? Where/how to find it? In Macland it's called the terminal emulator: http://en.wikipedia.org/wiki/Terminal_%28OS_X%29 -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a counter
On Thu, Oct 16, 2014 at 7:44 AM, Simon Kennedy wrote: > When you looked through the other answers and found a solution you're happy > with that does not use the standard library you can look through the > documentation and find a stdlib > (https://docs.python.org/2.7/library/index.html) provided way that may be > slightly more elegant for counting strings. I would have suggested a Counter if I thought it fit the OP's use case. If you're listing directory contents, you're not going to have any repeated strings, so all the counts will be 1, and your Counter might as well be a list, which is what you got from calling os.listdir() in the first place. So I was more inclined to think that the OP was only trying to count one thing. In any case, the question turned out to actually be about printing, not counting. -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there an easy way to control indents in Python
On Wednesday, 15 October 2014 20:31:15 UTC+1, Ian wrote: > I agree. I very rarely use blank lines inside functions. As I see it, > if you feel you need a blank line for separation within a function, > that's an indication your function is overly complex and should be > broken up. Whereas I feel that if I wanted to write code which looked like that I'd have learnt/learned Perl ;-) Each to their own. -- https://mail.python.org/mailman/listinfo/python-list
Re: Creating a counter
On Thursday, 16 October 2014 15:05:47 UTC+1, Ian wrote: > I would have suggested a Counter if I thought it fit the OP's use > case. If you're listing directory contents, you're not going to have > any repeated strings, so all the counts will be 1, and your Counter > might as well be a list, which is what you got from calling > os.listdir() in the first place. So I was more inclined to think that > the OP was only trying to count one thing. I read the OP's question as he was looking for the string in the contents of each file in the directory not in the file names themselves but as you say... > In any case, the question turned out to actually be about printing, > not counting. -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the easiest way to install multiple Python versions?
On Thu, Oct 16, 2014 at 11:31 PM, Albert-Jan Roskam wrote: > Most things were indeed easy to solve. But this one surprised me. With Python > 2.6, I need to outcomment the 'lambda' line. The error is what I get in > Python 2.6. It does not matter if I do u"\n".join(het_logboek[i:]). I don't > use latin-1 anywhere in my program. I need to convert unicode to bytes in > Python 2.6, or else it chokes in the smart quote. > Hmm, that looks like a configuration difference between the two, rather than a major breaking difference. It'll depend on the console settings; if you're running 2.6 from cron, but 2.7 from the console (or the other way around), you'll see stuff like this break. It's also possible that a bug was discovered, of course, but what exactly the bug is, I can't say. The error you're seeing is perfectly correct: you have Unicode character U+2018 (a curly quote) in your stream, and the print statement is trying to send that to a Latin-1 output, and that's not going to work. The question is, why is your console believed to be set to Latin-1? And if encoding UTF-8 works, then there's something very VERY wrong. (Unless by "works" you just mean "doesn't throw an error", and the UTF-8 bytes are being interpreted as Latin-1 bytes.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there an easy way to control indents in Python
On Fri, Oct 17, 2014 at 1:08 AM, Simon Kennedy wrote: > On Wednesday, 15 October 2014 20:31:15 UTC+1, Ian wrote: >> I agree. I very rarely use blank lines inside functions. As I see it, >> if you feel you need a blank line for separation within a function, >> that's an indication your function is overly complex and should be >> broken up. > > Whereas I feel that if I wanted to write code which looked like that I'd have > learnt/learned Perl ;-) I did learn Perl. That's why I now code in Python. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On Fri, Oct 17, 2014 at 1:04 AM, MRAB wrote: > In Macland it's called the terminal emulator: > > http://en.wikipedia.org/wiki/Terminal_%28OS_X%29 To be strictly correct, the "shell" would be the thing you run that gives you a prompt, and the "terminal emulator" would be the thing you run that gives you a black box on your GUI. On my Linux box here (Debian Wheezy with Xfce), I use xfce4-terminal as my terminal emulator, and bash as my shell. You could alternatively use gnome-terminal, or you could use csh for your shell, or whatever strikes your fancy. Macs are no different here; they have a terminal emulator (which is usually just called "Terminal" aiui), and a shell (usually bash, though not quite the bash I know from my systems - maybe a different version). It's Windows that is the oddball. You can't easily find the terminal emulator, though it does have one. People think of "running cmd.exe" to get a "shell", which in reality is both a terminal and a shell inside that terminal. But ultimately, it's still the same. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On 2014-10-16, Chris Angelico wrote: > On Fri, Oct 17, 2014 at 1:04 AM, MRAB wrote: >> In Macland it's called the terminal emulator: >> >> http://en.wikipedia.org/wiki/Terminal_%28OS_X%29 > > To be strictly correct, the "shell" would be the thing you run that > gives you a prompt, and the "terminal emulator" would be the thing > you run that gives you a black box on your GUI. Infidel! The correct color for an empty terminal box is _white_. You probably eat your soft-boiled eggs from the wrong end too. ;) -- Grant Edwards grant.b.edwardsYow! Everybody is going at somewhere!! It's probably gmail.coma garage sale or a disaster Movie!! -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On Fri, Oct 17, 2014 at 3:23 AM, Grant Edwards wrote: > On 2014-10-16, Chris Angelico wrote: >> On Fri, Oct 17, 2014 at 1:04 AM, MRAB wrote: >>> In Macland it's called the terminal emulator: >>> >>> http://en.wikipedia.org/wiki/Terminal_%28OS_X%29 >> >> To be strictly correct, the "shell" would be the thing you run that >> gives you a prompt, and the "terminal emulator" would be the thing >> you run that gives you a black box on your GUI. > > Infidel! The correct color for an empty terminal box is _white_. > > You probably eat your soft-boiled eggs from the wrong end too. > I probably do! Though I haven't yet figured out how to eat them from the inside. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Convert Qstring to string in windows
On Thu, Oct 16, 2014 at 8:21 AM, C@rlos wrote: > > I have been tryed to convert a Qstring text to string on python, in linux > that work fine but in windows when qstring contine á,é,í,ó,ú the converted > text is not correct, contine extranger characters, > this qstring text is an url from qdialogtext. > > in linux i do for this way: > pythonstringtext=qstringtext.text().toUtf8.data() > and it return a python string correctly. Hi Carlos, This seems like a question that's very specific to Qt: you may want to ask on a Qt-Python mailing list. Tutor is intended for beginner programmers, and the question you're asking seems a bit specialized for the intended audience. In absence of this information, I have to make a few guesses. My best guesses so far are that you're working with Qt, which provides its own Unicode string class: http://qt-project.org/doc/qt-4.8/qstring.html Are you using PyQt 4 or PyQt 5, or something else entirely? Are you using Python 2 or Python 3? According to the PyQt5 documentation, it automatically handles the string conversion: http://pyqt.sourceforge.net/Docs/PyQt5/gotchas.html#python-strings-qt-strings-and-unicode and according to the PyQt 4 documentation, it also handles the conversion automatically for you: http://pyqt.sourceforge.net/Docs/PyQt4/python_v3.html#qstring and because the mapping is done by the library, you should not have to be doing anything on your own end to convert Qstrings to Python strings. Yeah, I am not sure what you are doing yet, because the documentation says that it handles conversions for you. The fact that you're doing this manually suggests that you might be doing something unusual. We need more information. But I think you may get better help on a Qt-specific mailing list; I suspect very few of us here have Qt experience. -- https://mail.python.org/mailman/listinfo/python-list
Permissions on files installed by pip?
I've been using the python-nltk package on Ubuntu, but I need ntlk 3.0 now. I used 'sudo aptitude purge python-nltk' to get rid of my existing installation, & followed instructions on the nltk website [1] starting at step 4 (since I already have python-pip & python-numpy packages installed). $ sudo pip install -U I couldn't get it to work, until I realized that the permissions & ownership on /usr/local/lib/python2.7/dist-packages were 'drwx--S--- root staff'. A 'chmod -R a+rX' on that directory seems to have fixed it. Is it normal for sudo pip install to set the permissions that way, or did I do something wrong? [1] http://www.nltk.org/install.html -- Master Foo once said to a visiting programmer: "There is more Unix-nature in one line of shell script than there is in ten thousand lines of C."--- Eric Raymond -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Convert Qstring to string in windows
On 16/10/14 19:14, Danny Yoo wrote: need more information. But I think you may get better help on a Qt-specific mailing list; I suspect very few of us here have Qt experience. There are at least 2 Python Qt mailing lists and also two for Side which is Nokia's public domain fork of Qt. That's probably worth a look too. Definitely in the minority interest camp on the tutor list. hth -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Convert Qstring to string in windows
- On Thu, Oct 16, 2014 10:59 PM CEST Alan Gauld wrote: >On 16/10/14 19:14, Danny Yoo wrote: > >> need more information. But I think you may get better help on a >> Qt-specific mailing list; I suspect very few of us here have Qt >> experience. > >There are at least 2 Python Qt mailing lists and also two for >Side which is Nokia's public domain fork of Qt. That's probably >worth a look too. > >Definitely in the minority interest camp on the tutor list. > I am not 100 % sure but I think you can use str() on a qstring. In other words, it has its own __str__ method. -- https://mail.python.org/mailman/listinfo/python-list
Re: Import Doesn't Import
On 10/15/2014 5:40 PM, ryguy7272 wrote: ImportError: No module named 'urllib2' I'm telling Python to import because it doesn't exist and it throws an error. I don't get it; I just don't get it. If I'm working with R, I can import thousands of libraries with no errors whatsoever. With Python, I just get thousands of errors with nothing working whatsoever. I totally don't understand this language. Import means import. Right. WTF! So, maybe Import doesn't mean import -- perhaps you expect import to retrieve content from the web and make it importable(1). That's not what python's import does. Python's version looks for a local module to import. I'd suggest starting with the tutorial. Emile (1) which would imply execution of arbitrary code. -- https://mail.python.org/mailman/listinfo/python-list
Detecting user's installed Python/Tkinter packages during install of app
I am thinking of writing a new mac and/or windows application using python 3.x and the tkinter gui toolkit. A question that I have is this.. If my application uses a version of python/tkinter that is not on the users computer will I be able to detect that during an install and automatically install the proper files silently? Thanks in advance.. Noble -- https://mail.python.org/mailman/listinfo/python-list
Re: Detecting user's installed Python/Tkinter packages during install of app
On Thu, Oct 16, 2014 at 4:54 PM, Noble Bell wrote: > If my application uses a version of python/tkinter that is not on the users > computer will I be able to detect that during an install and automatically > install the proper files silently? You mean, like this? % python -c 'import _tkinter ; print _tkinter.TCL_VERSION' 8.5 Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On 16Oct2014 06:29, rusi wrote: On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: One may have to install activestate tkc/tk on mac, depending on osx version. This page has details: https://www.python.org/download/mac/tcltk Ok Ive some more information: The people in the audience using macs are using mavericks Whats the best way to setup python3 for that? I remember seeing some two different repos (if that what they are called in mac-land) for python. With some different tradeoffs which I dont understand. I use MacPorts. Also popular are Brew and Fink. You can even use them all at once; they install to separate trees. My Python 3 comes from MacPorts. Another related question for mac-python usage: I asked one of the mac-users: Please start your default python in a shell and tell me what version it is. Answer: Mac has no shell. I find this hard to believe. Is a shell called something else in mac-maverick?? Where/how to find it? As pointed out elsewhere, OSX ships with "Terminal" as a terminal emutator. Another popular terminal emulator is iTerm2, which is what I prefer. You can run X11 also, and use any of the many terminal emulators that run in it, though the experience is clunkier. As far as shells go, OSX ships with /bin/sh, /bin/bash and /bin/zsh. Or for the perverse, /bin/csh and /bin/tcsh (it is, after all, a BSD derived OS). I use zsh, getting my copy from MacPorts instead of OSX's native one. So it is a perfectly normal UNIX system in this regard. Cheers, Cameron Simpson No electrons were harmed in the production of this message. - Dr. P. Gensheimer -- https://mail.python.org/mailman/listinfo/python-list
Re: Import Doesn't Import
On Thu, Oct 16, 2014 at 5:29 PM, Emile van Sebille wrote: > On 10/15/2014 5:40 PM, ryguy7272 wrote: >> >> ImportError: No module named 'urllib2' >> I'm telling Python to import because it doesn't exist and it throws an >> error. I don't get it; I just don't get it. If I'm working with R, I can >> import thousands of libraries with no errors whatsoever. With Python, I >> just get thousands of errors with nothing working whatsoever. I totally >> don't understand this language. Import means import. Right. WTF! > > > So, maybe Import doesn't mean import -- perhaps you expect import to > retrieve content from the web and make it importable(1). That's not what > python's import does. Python's version looks for a local module to import. > > I'd suggest starting with the tutorial. > > Emile > > > (1) which would imply execution of arbitrary code. > > -- > https://mail.python.org/mailman/listinfo/python-list requests is a better choice than urllib -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Import Doesn't Import
On 16/10/2014 23:28, Joel Goldstick wrote: On Thu, Oct 16, 2014 at 5:29 PM, Emile van Sebille wrote: On 10/15/2014 5:40 PM, ryguy7272 wrote: ImportError: No module named 'urllib2' I'm telling Python to import because it doesn't exist and it throws an error. I don't get it; I just don't get it. If I'm working with R, I can import thousands of libraries with no errors whatsoever. With Python, I just get thousands of errors with nothing working whatsoever. I totally don't understand this language. Import means import. Right. WTF! So, maybe Import doesn't mean import -- perhaps you expect import to retrieve content from the web and make it importable(1). That's not what python's import does. Python's version looks for a local module to import. I'd suggest starting with the tutorial. Emile (1) which would imply execution of arbitrary code. -- https://mail.python.org/mailman/listinfo/python-list requests is a better choice than urllib To an experienced user yes, to an inexperienced OP who can't even run a Python program without help a very emphatic no. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On Friday, October 17, 2014 3:48:20 AM UTC+5:30, Cameron Simpson wrote: > On 16Oct2014 06:29, rusi wrote: > >On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: > >> One may have to install activestate tkc/tk on mac, depending on osx > >> version. This page has details: > >> https://www.python.org/download/mac/tcltk > >Ok Ive some more information: > >The people in the audience using macs are using mavericks > >Whats the best way to setup python3 for that? > >I remember seeing some two different repos (if that what they are called > >in mac-land) for python. With some different tradeoffs which I dont > >understand. > I use MacPorts. Also popular are Brew and Fink. You can even use them all at > once; they install to separate trees. Ok and is the MacPorts python3 one monolithic package or a bunch of separate ones (like debian/ubuntu) for core-python, tkinter, idle etc? -- https://mail.python.org/mailman/listinfo/python-list
Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?
On Tuesday, September 30, 2014 10:09:52 PM UTC+5:30, Rustom Mody wrote: > On Tuesday, September 30, 2014 8:48:15 PM UTC+5:30, c...@isbd.net wrote: > > Rustom Mody wrote: > > > On Tuesday, September 30, 2014 5:18:31 PM UTC+5:30, Chris wrote: > > > > I would actually > > > > quite like to keep the configuration data separate from the code as it > > > > would simplify using the data at the 'home' end of things as I'd just > > > > need to copy the configuration file across. This was why the database > > > > approach appealed at first as all I need to do is copy the database > > > > and everything is in there. > > > Of course > > > > Are there any better ways of doing this? E.g. some sort of standard > > > > configuration file format that Python knows about? > > > Umm this is getting to be a FAQ... > > > Maybe it should go up somewhere? > > > Yes there are dozens: > > > - ini > > > - csv > > > - json > > > - yml > > > - xml > > > - pickle > > > - And any DBMS of your choice > > > I guess Ive forgotten as many as Ive listed!! > > Yes, I know, I've found most of those. I'm really asking for help in > > choosing which to use. I think I can reject some quite quickly:- > > xml - horrible, nasty to edit, etc. I don't like XML! :-) > Heh! Youve proved yourself a pythonista! > > ini - doesn't work so well with lists/dictionaries (though possible) > > csv - rather difficult to edit > Have you tried with comma=tab? > > yml - front runner if I go for configuration files > Yeah my favorite as well > > json - one of the most likely possibilities, but prefer yml > Seems to be most popular nowadays -- maybe related to being almost yaml > and in the standard lib > > pickle - not user editable as I understand it > Well not in any reasonably pleasant way! > > What I'm really asking for is how to choose between:- > > python - just keep config in the modules/classes, not easy to use > > at 'both ends' (home and remote), otherwise quite simple > Can work at a trivial level. > As soon as things get a bit larger data and code mixed up is a recipe for > mess up. Just came across this https://github.com/henriquebastos/python-decouple/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Detecting user's installed Python/Tkinter packages during install of app
On Thursday, October 16, 2014 5:14:44 PM UTC-5, Skip Montanaro wrote: > On Thu, Oct 16, 2014 at 4:54 PM, Noble Bell wrote: > > > If my application uses a version of python/tkinter that is not on the users > > computer will I be able to detect that during an install and automatically > > install the proper files silently? > > > > You mean, like this? > > > > % python -c 'import _tkinter ; print _tkinter.TCL_VERSION' > > 8.5 > > > > Skip Not exactly. I mean when a end user is installing my application can the installer detect the presence of the correct version of python and tkinter and if they are not present have the installer silently install them to the users machine. NB -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there an easy way to control indents in Python
On 16/10/2014 12:32 AM, Chris “Kwpolska” Warrick wrote: Why? Because things like `print 'done'` usually have an empty line before it: Not in my code, they don't. I never put blank lines inside functions. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: python3 on mac-mavericks (was trying idle)
On 16Oct2014 18:08, rusi wrote: On Friday, October 17, 2014 3:48:20 AM UTC+5:30, Cameron Simpson wrote: On 16Oct2014 06:29, rusi wrote: >On Thursday, October 9, 2014 2:56:56 PM UTC+5:30, Terry Reedy wrote: >> One may have to install activestate tkc/tk on mac, depending on osx >> version. This page has details: >> https://www.python.org/download/mac/tcltk >Ok Ive some more information: >The people in the audience using macs are using mavericks >Whats the best way to setup python3 for that? >I remember seeing some two different repos (if that what they are called >in mac-land) for python. With some different tradeoffs which I dont understand. I use MacPorts. Also popular are Brew and Fink. You can even use them all at once; they install to separate trees. Ok and is the MacPorts python3 one monolithic package or a bunch of separate ones (like debian/ubuntu) for core-python, tkinter, idle etc? It is one package. (You can install distinct packages for python 3.2, 3.3, 3.4 ... and select which one is default.) That gets you Python and the stdlib. There's a whole suite of extra packages for various third party libraries. And of course the user can use pip and/or virtualenv to arrange things on their own, also. Cheers, Cameron Simpson People are paid for coming in the morning and leaving at night, and for saying "Good morning" in the morning and "Good afternoon" in the afternoon and never confusing the two. - Albert Shanker, president of the American Federation of Teachers -- https://mail.python.org/mailman/listinfo/python-list
2d color-bar map plot
Dear all, I am bit new to the python/pyplot. This might be simple, but I guess I am missing something here. I have data file as follows: 2.1576318858 -1.8651195165 4.2333428278 2.1681875208 -1.9229968780 4.1989176884 2.3387636157 -2.0376253255 2.4460899122 2.1696565965 -2.6186941271 4.4172007912 2.0848862071 -2.1708981985 3.3404520962 2.0824347942 -1.9142798955 3.3629290206 2.0281685821 -1.8103363482 2.5446721669 2.3309993378 -1.8721153619 2.7006893016 2.0957461483 -1.5379071451 4.5228264441 2.2761376261 -2.5935979811 3.9231744717 . . . (total of 200 lines) Columns 1,2,3 corresponds to x,y,z axis data points. This is not a continuous data. I wish to make a plot as a 2D with 3rd dimension (i.e z-axis data) as a color map with color bar on right hand side. As a beginner, I tried to follow tutorial with some modification as follows: http://matplotlib.org/examples/pylab_examples/tricontour_vs_griddata.html # Read data from file: fl1 = open('flooding-psiphi.dat','r').readlines() xs = ys = zs = [] for line in fl1: line = line.split() xs.append(float(line[0])) ys.append(float(line[1])) zs.append(float(line[2])) print xs[0], ys[0], zs[0] xi = np.mgrid[-5.0:5.0:200j] yi = np.mgrid[-5.0:5.0:200j] zi = griddata((x, y), z, (xi, yi), method='cubic') plt.subplot(221) plt.contour(xi, yi, zi, 15, linewidths=0.5, colors='k') plt.contourf(xi, yi, zi, 15, cmap=plt.cm.rainbow, norm=plt.Normalize(vmax=abs(zi).max(), vmin=-abs(zi).max())) plt.colorbar() # draw colorbar plt.plot(x, y, 'ko', ms=3) plt.xlim(-5, 5) plt.ylim(-5, 5) plt.title('griddata and contour (%d points, %d grid points)' % (npts, ngridx*ngridy)) #print ('griddata and contour seconds: %f' % (time.clock() - start)) plt.gcf().set_size_inches(6, 6) plt.show() However, I failed and getting long error as follows: QH6154 qhull precision error: initial facet 1 is coplanar with the interior point ERRONEOUS FACET: - f1 - flags: bottom simplicial upperDelaunay flipped - normal:0.7071 -0.70710 - offset: -0 - vertices: p600(v2) p452(v1) p304(v0) - neighboring facets: f2 f3 f4 While executing: | qhull d Qz Qbb Qt Options selected for Qhull 2010.1 2010/01/14: run-id 1531309415 delaunay Qz-infinity-point Qbbound-last Qtriangulate _pre-merge _zero-centrum Pgood _max-width 8.8 Error-roundoff 1.2e-14 _one-merge 8.6e-14 _near-inside 4.3e-13 Visible-distance 2.5e-14 U-coplanar-distance 2.5e-14 Width-outside 4.9e-14 _wide-facet 1.5e-13 precision problems (corrected unless 'Q0' or an error) 2 flipped facets The input to qhull appears to be less than 3 dimensional, or a computation has overflowed. Qhull could not construct a clearly convex simplex from points: - p228(v3): 2.4 2.4 1.4 - p600(v2): 1.4 1.4 8.8 - p452(v1): 5.7 5.7 8 - p304(v0): -3.1 -3.1 2.4 The center point is coplanar with a facet, or a vertex is coplanar with a neighboring facet. The maximum round off error for computing distances is 1.2e-14. The center point, facets and distances to the center point are as follows: center point1.5951.5955.173 facet p600 p452 p304 distance=0 facet p228 p452 p304 distance=0 facet p228 p600 p304 distance=0 facet p228 p600 p452 distance=0 These points either have a maximum or minimum x-coordinate, or they maximize the determinant for k coordinates. Trial points are first selected from points that maximize a coordinate. The min and max coordinates for each dimension are: 0:-3.134 5.701 difference= 8.835 1:-3.134 5.701 difference= 8.835 2: -2.118e-22 8.835 difference= 8.835 If the input should be full dimensional, you have several options that may determine an initial simplex: - use 'QJ' to joggle the input and make it full dimensional - use 'QbB' to scale the points to the unit cube - use 'QR0' to randomly rotate the input for different maximum points - use 'Qs' to search all points for the initial simplex - use 'En' to specify a maximum roundoff error less than 1.2e-14. - trace execution with 'T3' to see the determinant for each point. If the input is lower dimensional: - use 'QJ' to joggle the input and make it full dimensional - use 'Qbk:0Bk:0' to delete coordinate k from the input. You should pick the coordinate with the least range. The hull will have the correct topology. - determine the flat containing the points, rotate the points into a coordinate plane, and delete the other coordinates. - add one or more points to make the input full dimensional. Traceback (most recent call last): File "./scatter.py", line 43, in zi = griddata((x, y), z, (xi, yi), method='linear') File "/usr/lib/python2.7/dist-packages/scipy/interpolate/ndgriddata.py", line 183, in griddata ip = LinearNDInterpolator(points, values, fill_value=fill_value) File "interpnd.pyx", line 192, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__ (scipy/interpolate/inte