Re: Data transmission from Python script to bash script

2017-04-05 Thread dieter
venkatachalam...@gmail.com writes:
> ...
> I am writing a python code for processing a data obtained from a sensor. The 
> data from sensor is obtained by executing a python script. The data obtained 
> should be further given to another python module where the received data is 
> used for adjusting the location of an object.
>
> For achieving this, there is a central bash script, which runs both the 
> python modules parallel. Something like:
>
> python a.py &
> python b.py &
>
> I am trying to return the sensor data to the bash .sh file, therefore it can 
> be provided to the other script.

I would recommend, do not do it this way.

On an abstract level, I recommend to use a communication channel
between your "a" and your "b". "a" writes to it and "b" reads from it.

There are many, many options for such a communication channel.

One of the easiest would be to realisize "a" and "b" as tasks
in a single Python process which use a queue as communication channel.
The big advantage: "a" and "b" can communicate directly via python
objects.

Another option would be to implement the communication channel
via an external queue or file; in those cases, the Python object
created by "a" would need to be serialized (to be put into
the communication channel) and derialized (i.e. recreated) again by "b".

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Does automatic golden master unittest generation exist/or is it feasible?

2017-04-05 Thread dieter
fle...@gmail.com writes:

> I have a really large and mature codebase in py2, but with no test or 
> documentation.
>
> To resolve this I just had a simple idea to automatically generate tests and 
> this is how:
>
> 1. Have a decorator that logs all arguments and return values
>
> 2. Put them in a test case
>
> and have it run in production.

This works only for quite simple cases -- cases without state.

If you have something with state, than some function calls
may change the state and thereby changing the effect of later
function calls. This means: the same function call (same function,
same arguments) may give different results over time.

As a consequence, the initial state and the execution order
becomes important.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Data exchange between python script and bash script

2017-04-05 Thread Anssi Saari
venkatachalam...@gmail.com writes:

> For example, the data is printed in
> execute_sensor_process.py as follows:
>
> print >>sys.stderr,sens_data
>
> By printing the data onto sys.stderr and assigning a return variable in the 
> bash, I am expecting the data to be assigned.
>
> But this is not happening.

This part I can answer alhtough I'm not sure it helps with your actual
problems. 

Bash manual explicitly states command substition (the $(...) structure)
replaces the command with the standard *output* of the command. So since
your Python program writes to standard error, you get nothing.

-- 
https://mail.python.org/mailman/listinfo/python-list


How to make use of .egg files?

2017-04-05 Thread David Shi via Python-list
Can anyone explain please.
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make use of .egg files?

2017-04-05 Thread Ralf Hildebrandt
* David Shi via Python-list :
> Can anyone explain please.

http://stackoverflow.com/questions/2051192/what-is-a-python-egg

-- 
Ralf Hildebrandt   Charite Universitätsmedizin Berlin
ralf.hildebra...@charite.deCampus Benjamin Franklin
https://www.charite.de Hindenburgdamm 30, 12203 Berlin
Geschäftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "pandas" pronunciation

2017-04-05 Thread Neil Cerutti
On 2017-04-03, Jay Braun  wrote:
> I hear people say it like the plural of "panda", and others as
> "panduss".  Is there a correct way?

I think it is pronounced like the regular word. The second a is
schwa in both the singular and plural.

-- 
Neil Cerutti

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread Python

Le 05/04/2017 à 16:54, DFS a écrit :

I have identical databases in sqlite and postgres.  I want to run the
same code against them, but am having a small issue.

Current code below throws the dreaded:

NameError: global name 'db' is not defined

on line 12

How do I fix it?  I want to keep dbconnect() as a separate function.

Thanks.

-
1 import sqlite3, psycopg2
2
3 def dbconnect(dbtype):
4   if dbtype == "sqlite":
5 conn = sqlite3.connect(cstr)
6   elif dbtype == "postgres":
7 conn = psycopg2.connect(cstr)


8   return conn.cursor()


9
10 def updatedb(dbtype):


11   db = dbconnect(dbtype)


12   db.execute("DML code")
13   print "updated " + dbtype
14   'close connection

15 def main():
16   updatedb('sqlite')
17   updatedb('postgres')
18
19 if __name__ == "__main__":
20   main()
-




--
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread Joel Goldstick
On Wed, Apr 5, 2017 at 11:09 AM, Python  wrote:
> Le 05/04/2017 à 16:54, DFS a écrit :
>>
>> I have identical databases in sqlite and postgres.  I want to run the
>> same code against them, but am having a small issue.
>>
>> Current code below throws the dreaded:
>>
>> NameError: global name 'db' is not defined
>>
>> on line 12
>>
>> How do I fix it?  I want to keep dbconnect() as a separate function.
>>
>> Thanks.
>>
>> -
>> 1 import sqlite3, psycopg2
>> 2
>> 3 def dbconnect(dbtype):
>> 4   if dbtype == "sqlite":
>> 5 conn = sqlite3.connect(cstr)
>> 6   elif dbtype == "postgres":
>> 7 conn = psycopg2.connect(cstr)
>
>
> 8   return conn.cursor()
>
>> 9
>> 10 def updatedb(dbtype):
>
>
> 11   db = dbconnect(dbtype)
>
>> 12   db.execute("DML code")
>> 13   print "updated " + dbtype
>> 14   'close connection
>>
>> 15 def main():
>> 16   updatedb('sqlite')
>> 17   updatedb('postgres')
>> 18
>> 19 if __name__ == "__main__":
>> 20   main()
>> -
>>
>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list

You may have an indentation problem that isn't apparent in your code
pasted here.  Are you sure that dbconnect always returns something?

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread John Gordon
In  DFS  writes:

> I have identical databases in sqlite and postgres.  I want to run the 
> same code against them, but am having a small issue.

> Current code below throws the dreaded:

> NameError: global name 'db' is not defined

> on line 12

> How do I fix it?  I want to keep dbconnect() as a separate function.

Instead of trying to make db global, dbconnect() can return the db object:

def dbconnect(dbtype):
if dbtype == "sqlite":
conn = sqlite3.connect(cstr)
elif dbtype == "postgres":
conn = psycopg2.connect(cstr)
return conn.cursor()

def updatedb(dbtype):
db = dbconnect(dbtype)
db.execute("DML code")
print "updated " + dbtype
'close connection

It would probably be even better to return conn, as that would allow
updatedb() to call conn.disconnect().

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

-- 
https://mail.python.org/mailman/listinfo/python-list


How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread David Shi via Python-list


I tried the following codes:
import urllib2response = 
urllib2.urlopen('http://cordis.europa.eu/search/result_en?q=uk&format=csv')myCSV
 = response.read()
myFile = pd.read_csv(myCSV)

but, it did not work well.
Can any one help?
Regards.
David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 10:54:29 -0400, DFS wrote:

> I have identical databases in sqlite and postgres.  I want to run the 
> same code against them, but am having a small issue.
> 
> Current code below throws the dreaded:
> 
> NameError: global name 'db' is not defined
> 
> on line 12
> 
> How do I fix it?  I want to keep dbconnect() as a separate function.
> 
> Thanks.
> 
> -
> 1 import sqlite3, psycopg2
> 2
> 3 def dbconnect(dbtype):
> 4   if dbtype == "sqlite":
> 5 conn = sqlite3.connect(cstr)
> 6   elif dbtype == "postgres":
> 7 conn = psycopg2.connect(cstr)
> 8   db = conn.cursor()

This line just sets db locally to dbconnect.

You'll have to return it in order to use it elsewhere.

Add a line like this:

return db

> 9 
> 10 def updatedb(dbtype):
> 11   dbconnect(dbtype)

And then use the return value from dbconnect to create a new db locally
to updatedb:

db = dbconnect(dbtype)

> 12   db.execute("DML code")
> 13   print "updated " + dbtype
> 14   'close connection
> 
> 15 def main():
> 16   updatedb('sqlite')
> 17   updatedb('postgres')
> 18
> 19 if __name__ == "__main__":
> 20   main()
> -

HTH,
Dan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make use of .egg files?

2017-04-05 Thread breamoreboy
On Wednesday, April 5, 2017 at 2:00:41 PM UTC+1, David Shi wrote:
> Can anyone explain please.
> Regards.
> David

Egg files are old, wheels are the new thing http://pythonwheels.com/

Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread Skip Montanaro
I'm not positive, but try passing response to read_csv() instead of reading
the bytes yourself.

Skip

On Apr 5, 2017 10:38 AM, "David Shi via Python-list" 
wrote:

>
>
> I tried the following codes:
> import urllib2response = urllib2.urlopen('http://cordis.europa.eu/search/
> result_en?q=uk&format=csv')myCSV = response.read()
> myFile = pd.read_csv(myCSV)
>
> but, it did not work well.
> Can any one help?
> Regards.
> David
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread Peter Otten
David Shi via Python-list wrote:

> I tried the following codes:
> import urllib2response =
> 
urllib2.urlopen('http://cordis.europa.eu/search/result_en?q=uk&format=csv')myCSV
> = response.read() myFile = pd.read_csv(myCSV)
> 
> but, it did not work well.
> Can any one help?

Looks like read_csv() accepts an URL:

>>> import pandas
>>> url = "http://cordis.europa.eu/search/result_en?q=uk&format=csv";
>>> df = pandas.read_csv(url, sep=";")
>>> df.Title[0]
'Incremental Nonlinear flight Control supplemented with Envelope ProtecTION 
techniques'


-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3.6 printing crashing on OS X 10.12.4

2017-04-05 Thread Ray Cote
Hello:

Python 3.6 crashing when trying to print from the environment.

$ python
Python 3.6.1 (default, Mar 22 2017, 15:53:21)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello")

Python(53390,0x7fffdd9e63c0) malloc: *** error for object 0x10dde4110:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6


Pastebin link to OS X crash report if that’s helpful:
https://pastebin.com/t1j3nz5L


1: Python installed via ports.
2: OS X 10.12.4.
3: Python 3.6.1 (though I also had this problem with 3.6.0).
4: Have successfully run python 3.5 for months.
5: Running under standard terminal program.
6: I have py36-readline installed.
7: Have tried uninstalling and re-installing Python.

Any thoughts on what I could have wrong?

Regards
—Ray
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread David Shi via Python-list
Hi, Skip,
This is something very different.
New thinking and methods are needed.
Try to click on the following link
European Commission : CORDIS : Search : Results page


| 
| 
| 
|  |  |

 |

 |
| 
|  | 
European Commission : CORDIS : Search : Results page
European Commission |  |

 |

 |



Is there a way to capture the file?
Regards.
David
 

On Wednesday, 5 April 2017, 17:19, Skip Montanaro 
 wrote:
 

 I'm not positive, but try passing response to read_csv() instead of reading 
the bytes yourself.
Skip
On Apr 5, 2017 10:38 AM, "David Shi via Python-list"  
wrote:



I tried the following codes:
import urllib2response = urllib2.urlopen('http:// cordis.europa.eu/search/ 
result_en?q=uk&format=csv') myCSV = response.read()
myFile = pd.read_csv(myCSV)

but, it did not work well.
Can any one help?
Regards.
David
--
https://mail.python.org/ mailman/listinfo/python-list



   
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.6 printing crashing on OS X 10.12.4

2017-04-05 Thread Python

Le 05/04/2017 à 20:14, Ray Cote a écrit :

Hello:

Python 3.6 crashing when trying to print from the environment.

$ python
Python 3.6.1 (default, Mar 22 2017, 15:53:21)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

print("hello")


Python(53390,0x7fffdd9e63c0) malloc: *** error for object 0x10dde4110:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6


Pastebin link to OS X crash report if that’s helpful:
https://pastebin.com/t1j3nz5L


1: Python installed via ports.
2: OS X 10.12.4.
3: Python 3.6.1 (though I also had this problem with 3.6.0).
4: Have successfully run python 3.5 for months.
5: Running under standard terminal program.
6: I have py36-readline installed.
7: Have tried uninstalling and re-installing Python.

Any thoughts on what I could have wrong?

Regards
—Ray



Mac OS X 10.12.3, Python 3 installed by brew

mac:~$ uname -r
16.4.0
mac:~$ python3
Python 3.6.0 (default, Mar  4 2017, 12:32:34)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello")
hello

--
https://mail.python.org/mailman/listinfo/python-list


Using TKinter to show popular tweets from twitter API (Tweepy)

2017-04-05 Thread unihno
hello 
I'm building a python app where it should show the popular tweets in boxex in 
line with each other using TKinter. The problem is that the labels of the 
tweets are showing at the bottom of each other and i want them to be in boxes 
like this:

    
|  | |  | |  | |  |
    
    
|  | |  | |  | |  |
    
    
|  | |  | |  | |  |
    

this is my code:

from Tkinter import *
import tweepy
from local import *
import Tkinter as tk

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
api = tweepy.API(auth)
sa_ID = 23424938
large_text_size = 12
text_size = 20

#create obj in the root page (main windows)
root= Tk()
root.title("The news Portal")
root.configure(background='black')
trends1 = api.trends_place(id=sa_ID)
data = trends1[0]
# grab the trends
trends = []
trends=data['trends']
for trend in trends:
if trend['name'].startswith('#'):
for status in tweepy.Cursor(api.search, q=trend['name'], 
result_type='popular').items(1):
f = tk.Frame(root, background='black', borderwidth=2, 
relief="groove").pack()
Label(text=('@' + status.user.screen_name, "tweeted: 
",status.text)).pack()

root.mainloop()



please help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 14:56:12 -0400, DFS wrote:

> I split the database connection code and settings into a module, so
> the connection and setting values are available to other code modules
> I have.

Good work.

> dbset.py
> -
> import sqlite3, psycopg2, cx_Oracle
> 
> def openconnection(dbtype):
>if dbtype == "sqlite":
>   dbName = "DB.sqlite"
>   conn   = sqlite3.connect(dbName)
>   conn.text_factory = str
>   ps = '?'   #query parameter symbol
> 
>if dbtype == "postgres":
>   dbName = "DB on Postgres"
>   connectstring = "" \
>   " host = 'localhost' " \
>   " dbname   = 'dbname' "\
>   " user = 'USR' "   \
>   " password = 'PW' "
>   conn = psycopg2.connect(connectstring)
>   ps = '%s'   #query parameter symbol
> 
>if dbtype == "oracle":
> 'settings

Consider adding some sort of error checking.  One way would be to use
elif throughout and an else clause at the end to catch the errors,
something like this:

  if dbtype == '"x":
dbName = ...
  elif dbtype == "y":
dbName = ...
  :
  :
  :
  else:
raise ValueError("unknown database type: %s" % dbtype)

>db = conn.cursor()
>return [conn,db,dbName,ps]

These values could be encapsulated into a class, but a list or a tuple
works.  A small step might be a named tuple (one of the batteries
included with Python).

Clunky is in the eye of the beholder.  That appears to be clear,
effective, and easily extensible if you ever add another database
server.  And never underestimate code that works.  Ever.

> In other modules, add:
> 
> import dbset
> 
> dbconnect = dbset.openconnection(dbtype)
> conn   = dbconnect[0]
> db = dbconnect[1]
> dbName = dbconnect[2]
> ps = dbconnect[3]
> 
> or shorter version:
> 
> c = dbset.openconnection(dbtype)
> conn,db,dbName,ps = c[0],c[1],c[2],c[3]
> 

Or even shorter version:

  conn,db,dbName,ps = dbset.openconnection(dbtype)

Python will unpack that list for you.

> With that in place, I can do stuff like:
> 
> print "updating " + dbName
> db.execute("DML code")
> conn.commit()
> conn.close()
> db.close()

Yep.  :-)

And if you find yourself repeating that sequence of statements over and
over, then wrap them into a function:

  def execute_database_command(dbName, conn, db, dml_statement):
print "updating " + dbName
db.execute(dml_statement)
conn.commit()
conn.execute()
db.close()

and then the rest of your code is just:

  execute_database_command(db, conn, "DML code")
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request Help With pkexec

2017-04-05 Thread Wildman via Python-list
On Mon, 03 Apr 2017 14:29:56 -0500, Wildman wrote:

> Python 3.4.2
> Tkinter 8.6
> GCC 4.9.1 on Linux
> 
> I am working on a gui program using Tkinter. The program will
> have a feature to restart as root.  I am testing different gui
> front-ends from a terminal to raise privileges and I want to
> be able to use as many as possible for obvious reasons.  Gksu,
> kdesudo and su-to-root all work perfectly.  However, I have a
> problem with pkexec.  Here is the command I am using from a
> terminal:
> 
> $ pkexec python3 /home/user/Python/linfo-tk/linfo-tk.py
> 
> I get this error:
> 
> Traceback (most recent call last):
>   File "/home/user/Python/linfo-tk/linfo-tk.py", line 455, in 
> root = tk.Tk()
>   File "/usr/lib/python3.4/tkinter/__init__.py", line 1854, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive, 
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable

I am posting this follow-up for any Linux developer that might
be working on a gui program that requires root permissions.
My research revealed that programs like gksu are not going to
be supported long term.  Some distros have already dropped
gksu in favor of pkexec.

Pkexec is part of the PolicyKit package, policykit-1.  By
default it will not work with gui (X11) programs but that
behavior can be changed by using a .policy file placed in
/usr/share/polkit-1/actions/.  Once I created such a file,
pkexec worked perfectly with my program.  So my problem
was not Python related.

Below is the actual .policy file I am using.  It could be
edited to work with any program.  Lots of info on the
web about pkexec and the HTML .policy file.  Just search
on something like "run program with pkexec".  The name
of the file is com.ubuntu.pkexec.linfo-tk.policy.  Here
is the contents:



http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd";>



  Wildman Productions
  
Authentication is required to run Linfo-tk as root

  auth_admin
  auth_admin
  auth_admin

/opt/linfo-tk/linfo-tk.py
TRUE
  




-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to capture a CSV file and read it into a Pandas Dataframe?

2017-04-05 Thread Skip Montanaro
David> This is something very different.

David> New thinking and methods are needed.

David> Try to click on the following link

David> European Commission : CORDIS : Search : Results page


Hopefully not too very different. :-)

Looks to me like UTF-32 or UTF-16 encoding, or one of those encodings which
needs a BOM. I was able to read it using Python's csv module (this in
Python 3):

>>> f = open("cordis-search-results.csv")
>>> rdr = csv.DictReader(f, delimiter=';')
>>> for row in rdr:
...   print(row["Title"])
...
Incremental Nonlinear flight Control supplemented with Envelope ProtecTION
techniques
AdvancEd aicRaft-noIse-AlLeviation devIceS using meTamaterials
Imaging Biomarkers (IBs) for Safer Drugs: Validation of Translational
Imaging Methods in Drug Safety Assessment (IB4SD-TRISTAN)
Big Data for Better Outcomes, Policy Innovation and Healthcare System
Transformation (DO->IT)
Translational quantitative systems toxicology to improve the understanding
of the safety of medicines
Real world Outcomes across the AD spectrum for better care: Multi-modal
data Access Platform
Models Of Patient Engagement for Alzheimer’s Disease
INtestinal Tissue ENgineering Solution
Small vessel diseases in a mechanistic perspective: Targets for
InterventionAffected pathways and mechanistic exploitation for prevention
of stroke and dementia
How does dopamine link QMP with reproductive repression to mediate colony
harmony and productivity in the honeybee?


Note that I had to specify the delimiter as a semicolon. That also works
with pandas.read_csv:

>>> df = pd.read_csv("cordis-search-results.csv", sep=";")
>>> print(df["Title"])
0Incremental Nonlinear flight Control supplemen...
1AdvancEd aicRaft-noIse-AlLeviation devIceS usi...
2Imaging Biomarkers (IBs) for Safer Drugs: Vali...
3Big Data for Better Outcomes, Policy Innovatio...
4Translational quantitative systems toxicology ...
5Real world Outcomes across the AD spectrum for...
6Models Of Patient Engagement for Alzheimer’s D...
7   INtestinal Tissue ENgineering Solution
8Small vessel diseases in a mechanistic perspec...
9How does dopamine link QMP with reproductive r...
Name: Title, dtype: object


Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Using TKinter to show popular tweets from twitter API (Tweepy)

2017-04-05 Thread Terry Reedy

On 4/5/2017 3:48 PM, uni...@gmail.com wrote:


I'm building a python app where it should show the popular tweets

> in boxes in line with each other using TKinter.

By 'boxes' do you mean a visible border for Label widgets?  If so, you 
have to configure one.  You don't below.


> The problem is that the labels of the tweets are showing at
> the bottom of each other

I don't understand this, and cannot run your code to see what it does.


and i want them to be in boxes like this:


snip


this is my code:

from Tkinter import *
import tweepy
from local import *
import Tkinter as tk


Use just 1 of the 2 tkinter imports.


auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
api = tweepy.API(auth)


For initial development of the UI, and especially when asking for help, 
use static data included within the file.  In this case, a short list of 
'status' items with the required attributes.  Read 
https://stackoverflow.com/help/mcve



for status in tweepy.Cursor(api.search, q=trend['name'], 
result_type='popular').items(1):


for status in myshortlist:


f = tk.Frame(root, background='black', borderwidth=2, 
relief="groove").pack()


Commen error.
.pack(), etc is a status mutation method and returns None.
You did not get an exception only because f is not used.


Label(text=('@' + status.user.screen_name, "tweeted: 
",status.text)).pack()


You omitted the master, so it defaults to the more or less undocumented 
default root.  It this context, this should be the explicit 'root' 
defined previously.  I recommend being explicit, always.


I did not know that the 'string' passed as 'text' could be a tuple of 
strings.  I don't know if it is documented anywhere.  My simple 
experiment suggested that the result is ' '.join(strings), as with print 
calls.  But I don't know it that is always true.


Multiple Labels should be packed vertically, with each centered.  If you 
want lined up to the left, you will have to say so.  As I said, I don't 
know what you saw.


> Please help

Please make it easier by posting a better question, including an mcve.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Data exchange between python script and bash script

2017-04-05 Thread Gregory Ewing

Anssi Saari wrote:

Bash manual explicitly states command substition (the $(...) structure)
replaces the command with the standard *output* of the command.


Another problem is your use of '&' here:

   sensor_data=$(python execute_sensor_process.py) &

The '&' causes the whole command, including the variable
assignment, to be executed in a subshell. So the variable
is only bound in the subshell process and won't be seen
from the main shell process.

Running the command in the background here is pointless,
since if the shell script needs the variable value for
subsequent processing it will have to wait for the
command to finish. So just get rid of the '&'.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: "pandas" pronunciation

2017-04-05 Thread Gregory Ewing

Neil Cerutti wrote:

On 2017-04-03, Jay Braun  wrote:


I hear people say it like the plural of "panda", and others as
"panduss".  Is there a correct way?


I think it is pronounced like the regular word. The second a is
schwa in both the singular and plural.


I think the OP is referring to the distinction between
"pandas" with an unvoiced "s", and "pandaz", as in the
plural of "panda".

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Problem installing 3.6.1 AMD64

2017-04-05 Thread Colin J. Williams
   Successful install reported, but:

 Microsoft Windows [Version 10.0.14393]
 (c) 2016 Microsoft Corporation. All rights reserved.

 C:\Users\CJW>cd\python
 The system cannot find the path specified.

 C:\Users\CJW>cd\

 C:\>path
 PATH=C:\Program Files\Python35\Scripts\;C:\Program
 Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
 
32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
 Files (x86)\ATI Technologi
 es\ATI.ACE\Core-Static;C:\Program Files
 
(x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
 C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
 Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
 C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
 (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
 
ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
 
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
 Files (x86)\
 ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
 (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
 Users\CJW\AppData\Local\Microsoft\WindowsApps;

 C:\>

   Python35 has been deleted, but it remains in the PATH.

   I would welcome advice.

   Colin W.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem installing 3.6.1 AMD64

2017-04-05 Thread eryk sun
On Wed, Apr 5, 2017 at 6:46 PM, Colin J. Williams  wrote:
>Successful install reported, but:
>
>  Microsoft Windows [Version 10.0.14393]
>  (c) 2016 Microsoft Corporation. All rights reserved.

You're using Windows 10.

>  C:\Users\CJW>cd\python
>  The system cannot find the path specified.
>
>  C:\Users\CJW>cd\

What is this supposed to be doing?

>  C:\>path
>  PATH=C:\Program Files\Python35\Scripts\;C:\Program
>  Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
>  
> 32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
>  Files (x86)\ATI Technologi
>  es\ATI.ACE\Core-Static;C:\Program Files
>  
> (x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
>  C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
>  Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
>  C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
>  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
>  
> ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
>  
> Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
>  Files (x86)\
>  ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
>  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
>  Users\CJW\AppData\Local\Microsoft\WindowsApps;
>
>  C:\>
>
>Python35 has been deleted, but it remains in the PATH.
>
>I would welcome advice.

The environment variable editor in Windows 10 has made editing PATH
about as easy as possible. Just manually remove (select and click on
"Delete") whichever paths are no longer valid. Apparently one is
per-machine in "C:\Program Files\Python35", which will likely be in
the system PATH, and the other is per-user in
"C:\Users\CJW\AppData\Local\Programs\Python\Python35", which will
likely be in the user PATH.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem installing 3.6.1 AMD64

2017-04-05 Thread MRAB

On 2017-04-05 19:46, Colin J. Williams wrote:

Successful install reported, but:

  Microsoft Windows [Version 10.0.14393]
  (c) 2016 Microsoft Corporation. All rights reserved.

  C:\Users\CJW>cd\python
  The system cannot find the path specified.

  C:\Users\CJW>cd\

  C:\>path
  PATH=C:\Program Files\Python35\Scripts\;C:\Program
  Files\Python35\;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system
  
32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\ATI Technologi
  es\ATI.ACE\Core-Static;C:\Program Files
  
(x86)\AMD\ATI.ACE\Core-Static;C:\WINDOWS\system32\config\systemprofile\.dnx\bin;
  C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL
  Server\130\Tools\Binn\;C:\Program Files\TortoiseHg\;
  C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Progra
  
ms\Python\Python35\Scripts\;C:\Users\CJW\AppData\Local\Programs\Python\Python35\;C:\Python35\Lib\site-packages\PyQt5;C:\
  
Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
  Files (x86)\
  ATI Technologies\ATI.ACE\Core-Static;C:\Program Files
  (x86)\Skype\Phone\;C:\Users\CJW\AppData\Local\Programs\Git\cmd;C:\
  Users\CJW\AppData\Local\Microsoft\WindowsApps;

  C:\>

Python35 has been deleted, but it remains in the PATH.

I would welcome advice.


It's easy enough to remove those references.

Try to start Python 3.5 to check that it's really gone:

C:\> py -3.5

It should complain if it's no longer there.

Start Python 3.6:

C:\> py -3.6

Have a look at the references to Python 3.5 in the PATH environment 
variable to double-check:


>>> import os
>>> [p for p in os.environ['PATH'].split(';') if 'Python35' in p]

Remove those references from the PATH environment variable:

>>> os.environ['PATH'] = ';'.join(p for p in 
os.environ['PATH'].split(';') if 'Python35' not in p)


Job done!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Problem installing 3.6.1 AMD64

2017-04-05 Thread eryk sun
On Thu, Apr 6, 2017 at 12:12 AM, MRAB  wrote:
 import os
 [p for p in os.environ['PATH'].split(';') if 'Python35' in p]
>
> Remove those references from the PATH environment variable:
>
 os.environ['PATH'] = ';'.join(p for p in os.environ['PATH'].split(';')
 if 'Python35' not in p)
>
> Job done!

Changing an environment variable in a process applies only to the
process and its descendants. It doesn't change the persistent value
that, on Windows, is stored in the registry. It's best to use the GUI
shell's environment-variable editor for this, for multiple reasons.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick questions about globals and database connections

2017-04-05 Thread Dan Sommers
On Wed, 05 Apr 2017 22:00:46 -0400, DFS wrote:

> I have a simple hard-coded check in place before even trying to connect:
> 
> if dbtype not in ('sqlite postgres'):
>print "db type must be sqlite or postgres"
>exit()

That's not doing what you think it is.

Hint:  What is ('sqlite postgres')?

> Good comments, Lt. Dan.  Thanks.

No problem.
-- 
https://mail.python.org/mailman/listinfo/python-list


fresh install setup error

2017-04-05 Thread scooter800m
hi i just installed python 3.6.1 32-bit on my windows 7 home premium
64-bit. and i get a file missing error. i reinstalled and used the
repairing thing and still no working python 3.6.1.

here is the error message that i get:
-- 
https://mail.python.org/mailman/listinfo/python-list