python-3.3

unexpected end of regular expression

﹥>﹥吖頭↗ 提交于 2019-12-02 03:04:54
I want to get only the file name with extension from the path: C:\\Users\\anandada\\workspace\\MyTestProject\\src\\OpenTest.c The statement below, fileName = re.match("[^\\]*.c$", fileName) gives error: unexpected end of regular expression I am using python 3.3.2 You need to double the doubled escapes again , or use a raw string instead: fileName = re.match("[^\\\\]*.c$",fileName) or fileName = re.match(r"[^\\]*.c$",fileName) otherwise first Python, then the regular expression compiler will interpret those backslashes, resulting in the ] being escaped: >>> print("[^\\]*.c$") '[^\]*.c$' Also

Shuffle a python list without using the built-in function

南笙酒味 提交于 2019-12-01 12:47:33
I'm working on writing two different shuffle functions. The first shuffle function must take a list and return a new list with the elements shuffled into a random order. This is what I have so far for the first shuffle function- def shuf(List): import random newList=[] for i in List: i=random.randrange(len(List)) newList+=i return newList The second shuffle function takes a list as a parameter and shuffles the list in place. I know how to do it with the built-in function but I'm not allowed to use it. You might find that this implementation for shuffling suits your needs. Make sure that you

Getting certificate chain with Python 3.3 SSL module

烂漫一生 提交于 2019-12-01 04:42:55
I can get the standard certificate information for an SSL connection in Python 3.3 via the getpeercert() method on the SSL socket. However, it doesn't seem to provide the chain like OpenSSL's "s_client" tool does. Is there some way I can get this so that I can see if my IA certificate was configured properly? s_client command-line: openssl s_client -connect google.com:443 s_client result (just the first few lines): $ openssl s_client -connect google.com:443 CONNECTED(00000003) depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA verify error:num=20:unable to get local issuer certificate

ReferenceError: “something” is not defined in QML

左心房为你撑大大i 提交于 2019-12-01 03:52:14
I have Main.qml file like this: import QtQuick 2.0 Rectangle { color: ggg.Colors.notificationMouseOverColor width: 1024 height: 768 } in python file, i have this(i use form PyQt5): App = QGuiApplication(sys.argv) View = QQuickView() View.setSource(QUrl('views/sc_side/Main.qml')) Context = View.rootContext() GlobalConfig = Config('sc').getGlobalConfig() print (GlobalConfig, type(GlobalConfig)) Context.setContextProperty('ggg', GlobalConfig) View.setResizeMode(QQuickView.SizeRootObjectToView) View.showFullScreen() sys.exit(App.exec_()) this python code print this for config: {'Colors': {

Python unclosed resource: is it safe to delete the file?

一世执手 提交于 2019-12-01 03:36:34
Googled my way around this issue, but didn't find any solutions. I'm running Python 3.3 with Eclipse and PyDev plugin, and when I run any Python project, I get the following message: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/update_checker.py:37: ResourceWarning: unclosed file <_io.BufferedReader name='/var/folders/x4/st67yr0x6qg7znh7sdfr94kh0000gn/T/update_checker_cache.pkl'> permacache = pickle.load(open(filename, 'rb')) I'm kind of new to Python, and I have no idea what this means. I wanted to ask before deleting this to make sure it's safe to delete.

Getting certificate chain with Python 3.3 SSL module

陌路散爱 提交于 2019-12-01 03:06:48
问题 I can get the standard certificate information for an SSL connection in Python 3.3 via the getpeercert() method on the SSL socket. However, it doesn't seem to provide the chain like OpenSSL's "s_client" tool does. Is there some way I can get this so that I can see if my IA certificate was configured properly? s_client command-line: openssl s_client -connect google.com:443 s_client result (just the first few lines): $ openssl s_client -connect google.com:443 CONNECTED(00000003) depth=2 C = US,

Using bisect in a list of tuples?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 23:20:43
问题 I'm trying to figure out how to use bisect in a list of tuples for example [(3, 1), (2, 2), (5, 6)] How can I bisect this list according to the [1] in each tuple? list_dict [(69, 8), (70, 8), ((65, 67), 6)] tup1,tup2 (69, 8) (70, 8) list_dict [((65, 67), 6)] fst, snd ((65, 67),) (6,) And I'm inserting to bisect idx = bisect.bisect(fst, tup1[1]+tup2[1]) Which gives me unorderable types: int() < tuple() 回答1: You can separate out the values into separate lists. from bisect import bisect data = [

Installing pip for python3.3

こ雲淡風輕ζ 提交于 2019-11-30 13:10:20
问题 I downloaded pip from Package Index > pip 1.2.1 Then I installed it using sudo python3.3 setup.py install Still, when I try to use pip-3.3 the terminal complains -bash: pip-3.3: command not found However, pip-2.7 works swimmingly. I have also tried curl -O http://python-distribute.org/distribute_setup.py sudo python3.3 distribute_setup.py sudo python3.3 -m easy_install pip But pip-3.3 still does not work. What do I do to install pip for Python 3.3? Note that there is a related thread How to

ImportError: No module named '_sqlite3' in python3.3

佐手、 提交于 2019-11-30 05:49:24
问题 sqlite3 error import sqlite3 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.3/sqlite3/__init__.py", line 23, in <module> from sqlite3.dbapi2 import * File "/usr/local/lib/python3.3/sqlite3/dbapi2.py", line 26, in <module> from _sqlite3 import * ImportError: No module named '_sqlite3' i use sqlite3 install command pip install pysqlite Downloading/unpacking pysqlite Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded Running setup.py

Python unclosed resource: is it safe to delete the file?

巧了我就是萌 提交于 2019-11-30 03:17:56
问题 Googled my way around this issue, but didn't find any solutions. I'm running Python 3.3 with Eclipse and PyDev plugin, and when I run any Python project, I get the following message: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/update_checker.py:37: ResourceWarning: unclosed file <_io.BufferedReader name='/var/folders/x4/st67yr0x6qg7znh7sdfr94kh0000gn/T/update_checker_cache.pkl'> permacache = pickle.load(open(filename, 'rb')) I'm kind of new to Python, and I