This pattern seems to work:
import sys
if sys.version_info[0] < 3:
raise RuntimeError("Must use at least python version 3")
# The 'typing' module, useful for type hints, was introduced in python 3.5
if sys.version_info[1] >= 5:
from typing import Optional
optional_float = Optional[fl
I think it's great that for built-in types such as int and str, backward
compatibility of type hinting annotations is baked into python 3.0 to 3.4. In
fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
doesn't...
I'm struggling to create something backward compatible that re
I'm starting out with Python 3.5. My current frustration is with:
>>> math.sqrt(25)
Traceback (most recent call last):
File "", line 1, in
math.sqrt(25)
NameError: name 'math' is not defined
>>>
Advice?
Jack
--
https://mail.python.org/mailman/listinfo/python-list
I want to let the name of an attribute be the string value of a variable. Here
is some code:
class Object(object): pass
A = Object()
s = 'attr'
A. = 1
The last line denotes the variable value by (not a python form). What I
want is to have A.attr = 1, but 'attr' determined by the value of s.
On Saturday, October 5, 2013 7:08:08 PM UTC-6, Harvey Greenberg wrote:
> I am looping as for L in file.readlines(), where file is csv.
>
>
>
> L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first
> item is a dir and 2nd is a li
On Sunday, October 6, 2013 10:41:33 AM UTC-6, Harvey Greenberg wrote:
> On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote:
>
> > On 2013-10-05 18:08, Harvey Greenberg wrote:
>
> >
>
> > > I am looping as for L in fi
On Saturday, October 5, 2013 7:24:39 PM UTC-6, Tim Chase wrote:
> On 2013-10-05 18:08, Harvey Greenberg wrote:
>
> > I am looping as for L in file.readlines(), where file is csv.
>
> >
>
> > L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3]
I am looping as for L in file.readlines(), where file is csv.
L is a list of 3 items, eg, [{'a':1, 'b':2}, [1,2,3], 10] Note that the first
item is a dir and 2nd is a list, so parsing with split doesn't work. Is there
a way to convert L, which is a string, to the list of 3 items I want?
--
ht
2009/7/13 Aaron Scott :
>> BTW, you should derive all your classes from something. If nothing
>> else, use object.
>> class textfile(object):
>
> Just out of curiousity... why is that? I've been coding in Python for
> a long time, and I never derive my base classes. What's the advantage
> to der
2009/7/13 seldan24 :
> Thank you both for your input. I want to make sure I get started on
> the right track. For this particular script, I should have included
> that I would take the exception contents, and pass those to the
> logging module. For this particular script, all exceptions are fata
2009/7/12 Cameron Pulsford :
> My question is, is it possible to combine those two loops? The primes
> generator I wrote finds all primes up to n, except for 2, 3 and 5, so I must
> check those explicitly. Is there anyway to concatenate the hard coded list
> of [2,3,5] and the generator I wrote so
2009/7/8 Dhananjay :
> I wanted to sort column 2 in assending order and I read whole file in array
> "data" and did the following:
>
> data.sort(key = lambda fields:(fields[2]))
>
> I have sorted column 2, however I want to count the numbers in the column 2.
> i.e. I want to know, for example, how
2009/7/6 Xavier Ho :
> Why is version B of the code faster than version A? (Only three lines
> different)
Here's a guess:
As the number you're testing gets larger, version A is creating very
big list. I'm not sure exactly how much overhead each list entry has
in python, but I guess it's at least
2009/7/4 Steven D'Aprano :
> On Sat, 04 Jul 2009 13:42:06 +, Steven D'Aprano wrote:
>
>> On Sat, 04 Jul 2009 10:55:44 +0100, Vilya Harvey wrote:
>>
>>> 2009/7/4 Andre Engels :
>>>> On Sat, Jul 4, 2009 at 9:33 AM, mclovin wrote:
>>&
2009/7/4 Patrick Sabin :
> If someone has another idea of taking a snapshot let me know. Using VMWare
> is not a
> very elegant way in my opinion.
Someone implemented the same idea for Java a while ago. They called it
"omniscient debugging"; you can find details at
http://www.lambdacs.com/debu
2009/7/4 Andre Engels :
> On Sat, Jul 4, 2009 at 9:33 AM, mclovin wrote:
>> Currently I need to find the most common elements in thousands of
>> arrays within one large array (arround 2 million instances with ~70k
>> unique elements)
>>
>> so I set up a dictionary to handle the counting so when I a
My client in Jersey City, NJ 07302 is looking for a Python Developer. Below
is the job description:
Job Summary:
This is a programming position in the technical department of Advance
Internet, working on application development, application integration,
automated testing and deployment of appli
t;':
#strip off the quotes and normalise spaces
ret.append(' '.join(x[1:-1].split()))
else:
ret.append(x)
return ret
query = ' " Some words" withand "withoutquotes " '
print findwords(query)
Running this gives
['Some words', 'with', 'and', 'without quotes']
HTH
Harvey
--
http://mail.python.org/mailman/listinfo/python-list
]* portion of my
> regex is being ignored, so only one match is being returned, starting
> at the first and ending at the end of the text, when it should
> end at the first . For this example, it should return three
> matches, one for each div.
>
> Is what I'm trying to do possible with Python's Regex library? Is
> there an error in my Regex?
>
> Thanks,
> Chris
print re.findall(r'<%s(?=[\s/>])[^>]*>' % 'div', r)
["", "", ""]
HTH
Harvey
--
http://mail.python.org/mailman/listinfo/python-list
Hello
Sending mail with certain characters in the body causes mail never to
arrive. Why?
e.g if body text has a fullstop "." mail never arrives.
I'm using python 4.2 on windows.
Harvey
#
range(0x20, 0xD7FF), iMessage)- Hide quoted
> text -
>
> - Show quoted text -
You need to explicitly convert the string of UTF8 encoded bytes to a
Unicode string before parsing e.g.
unicodestring = unicode(encodedbytes, 'utf8')
Unless I messed up copying and pasting, your
On May 22, 2:45 pm, "sim.sim" <[EMAIL PROTECTED]> wrote:
> Hi all.
> i'm faced to trouble using minidom:
>
> #i have a string (xml) within CDATA section, and the section includes
> "\r\n":
> iInStr = '\n\n'
>
> #After i create DOM-object, i get the value of "Data" without "\r\n"
>
> from xml.dom im
s not valid XML. It misses a xmlns:text namespace
> declaration. So you won't be able to parse it regardless of what parser you
> use.
>
> Diez- Hide quoted text -
>
> - Show quoted text -
The example is valid well-formed XML. It is permitted to use the ":"
character in element names. Whether one should in a non namespace
context is a different matter.
Harvey
--
http://mail.python.org/mailman/listinfo/python-list
Rickard Lindberg wrote:
> I see two potential problems with the non regex solutions.
>
> 1) Consider a line: "foo (bar)". When you split it you will only get
> two strings, as split by default only splits the string on white space
> characters. Thus "'bar' in words" will return false, even though
Rickard Lindberg wrote:
> I see two potential problems with the non regex solutions.
>
> 1) Consider a line: "foo (bar)". When you split it you will only get
> two strings, as split by default only splits the string on white space
> characters. Thus "'bar' in words" will return false, even though
Victor Polukcht wrote:
> My pattern now is:
>
> (?P[^(]+)(?P\d+)\)\s+(?P\d+)
>
> And i expect to get:
>
> var1 = "Unassigned Number "
> var2 = "1"
> var3 = "32"
>
> I'm sure my regexp is incorrect, but can't understand where exactly.
>
> Regex.debug shows that even the first block is incorrect.
>
Hugo Ferreira wrote:
> Hi!
>
> I'm trying to do a search-replace in places where some groups are
> optional... Here's an example:
>
> >> re.match(r"Image:([^\|]+)(?:\|(.*))?", "Image:ola").groups()
> ('ola', None)
>
> >> re.match(r"Image:([^\|]+)(?:\|(.*))?", "Image:ola|").groups()
> ('ola', '')
Hugo Ferreira wrote:
> Hi!
>
> I'm trying to do a search-replace in places where some groups are
> optional... Here's an example:
>
> >> re.match(r"Image:([^\|]+)(?:\|(.*))?", "Image:ola").groups()
> ('ola', None)
>
> >> re.match(r"Image:([^\|]+)(?:\|(.*))?", "Image:ola|").groups()
> ('ola', '')
శ్రీనివాస wrote:
> Hai friends,
> Can any one tell me how can i remove a character from a unocode text.
> కల్&హార is a Telugu word in Unicode. Here i want to
> remove '&' but not replace with a zero width char. And one more thing,
> if any whitespaces are there before and after '&' char, the text
Matt wrote:
> I am attempting to reformat a string, inserting newlines before certain
> phrases. For example, in formatting SQL, I want to start a new line at
> each JOIN condition. Noting that strings are immutable, I thought it
> best to spllit the string at the key points, then join with '\n'.
Fredrik Lundh wrote:
> when in doubt, ask the compiler:
MTD wrote:
> >>> dis.dis(cod)
Thanks so much guys! Python just gets cooler every day!
David
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
Suppose I write
if x in ("abc", "def", "xyz"):
doStuff()
elif x in ("pqr", "tuv", "123"):
doOtherStuff()
elif ...
etc.
When is python building the tuples? Does it need to build the tuple
every time it comes through this code? Or do
32 matches
Mail list logo