f))
'0xfff'
>>> hex(hash(0x1fff))
'0x0'
And up to that limit they're as widely distributed as you
can get -- each integer hashes to a unique value!
But keep in mind that the hash value itself is not directly
used to locate a dict slot --
ng the chain of frames into the call
stack and then resuming the last one.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
attribute of an object. Theoretically it's possible
for these to have side effects and for bad things to happen if you
skip them. But that would be very unusual and surprising, and we
generally assume such things don't happen.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 23/03/22 11:44 am, Rathmann wrote:
So that sounds like the original CPython implementation had an
O(depth) component, but with a lower constant factor than the current
version?
Yes, but so much lower that I would expect it to be unmeasurable.
--
Greg
--
https://mail.python.org/mailman
t of books with a given isbn (presumably
all copies of the same book).
It would make more sense for there only to be a list of books, and just
one reference to the student, at that point in the code.
Generally this whole piece of code seems hopelessly confused and needs
to be re-thought.
--
Script action, and save it as type Application.
The command should be something like
/path/to/desired/python /path/to/my/python_file.py
Note that the current directory will probably be the user's home
directory, so it's best to use full pathnames for everything.
--
Greg
--
https://mail.
nd video
memory. Experimentation is the only way to be sure.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ally it's easier and safer to
use the csv module for csv.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
others and doing it themselves,
so nobody writes anything down about it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.
If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
monospaced, but
it is designed for very low resolution, so it's probably a
reasonable choice for use on a small display.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
x
using an automated process. It sounds like an interesting
project, but be aware that it's probably an AI-complete
problem.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
code that does something
noticeable. You'll find that *any* form of import executes
all the top-level code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
table
statement that creates a class object and binds it to a name. There's
nothing stopping you from subsequently rebinding that name to some
other object, or deleting it altogether.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
hting.
Python differs from VBScript and other VB-family languages in that
names are case-sensitive. So it's common to use case to distinguish
between things such as a class and an instance.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
with a code example,
it would have to be run on a different implementation of Python
that didn't use reference counting, such as Jython.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
thon ?
You deal with it by not relying on __del__ for anything
that needs to be done promptly. There are always alternatives:
e.g. file objects have a close() method, and the "with"
statement was invented to make it easy to do these kinds
of things properly.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
know, all the details are unique
to Python. Some other languages have a "with" statement,
but it does something completely different.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 14/12/19 5:13 pm, boB Stepp wrote:
is it true that CPython itself is free to
implement these behaviors differently in its own future versions?
Yes. That's why it's not a good idea to rely on them even
if you only intend to run your code on CPython.
--
Greg
--
https://mail.
PyInit_XXX(), where XXX is computed from
the .pyx name,
You could try creating a set of top-level .pyx stubs, each of
which just 'include' the real code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ase:
for s in 'abc'.like( '(.)' ):
I would recommend making it a stand-alone function instead,
so that you would write
for s in like('abc', '(.)'):
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ten in the file in either order,
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ou
have to go out of your way to get things in a different
order.
But strangely, I tend to do the opposite for methods of
a class. I don't really know why. My instinctive idea of
the "right" ordering just seems to flip over somehow
between modules and classes.
--
Greg
--
https://mail
own to the bottom of the file and work backwards.
But it's not so easy for classes if you have more than one class
in a file. That might be part of the reason I do things the
opposite way in classes.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
It looks like what the OP is after already exists:
https://docs.python.org/3/library/zipapp.html
"This module provides tools to manage the creation of zip files
containing Python code, which can be executed directly by the Python
interpreter."
--
Greg
--
https://mail.python.o
ewhat advanced
topics, to be tackled after your students are familiar with the
basics.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
Perhaps getting zipextimporter into the standard library,
and developing versions of it for Linux and MacOS, would be
a useful improvement?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
whether it just needs to be something with a sufficiently
int-like interface.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
port from being opened.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
_']['__imp'+'ort__']",
{"__builtins__":{}})
You can probably find a way to block that particular loophole.
But then there will be another one, and another, and another...
You'll never be sure that you've found all of them.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ree assignment statements.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 29/01/20 6:27 pm, Peng Yu wrote:
Suppose that I use this to read from stdin. But `line` contains
decoded data in python 3. In python 2, it contains the original data.
What is the best way to get the original data in python 3?
Read from stdin.buffer, which is a stream of bytes.
--
Greg
On 3/02/20 3:38 am, Stefan Ram wrote:
void( ( print( 2 ), print( 3 )))
If the functions you're calling all return None, you can
do this:
>>> print(2); print(3)
2
3
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
e point of asyncio is to make tasks very lightweight, so you
can use as many of them as is convenient without worries. One task
per client sounds like the right thing to do here.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
blems need to be addressed by appropriate use of locks,
etc.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ion, while ensuring that there really
is only one instance, and making this fact clear to anyone
reading the code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
call a coroutine, so switching a
function between coroutine and non-coroutine would still have
just as much of a ripple effect on the rest of your code.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
the
tp_getattro type slot, which corresponds to __getattribute__.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
bort trap: 6
Am I out of luck? Is Python 3.8 only intended work on very recent
versions of MacOSX?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
version) but I think
I'm being bitten by the same underlying issue.
I'm going to try again with XCode 8, which purportedly comes
with a 10.12 SDK, and see if that fixes it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 22/03/20 10:20 pm, Greg Ewing wrote:
I'm going to try again with XCode 8, which purportedly comes
with a 10.12 SDK, and see if that fixes it.
It does.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
*should* be
eliminated, before thinking about how to achieve it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
7;, '__init__', '__new__',
'__thisclass__', '__self__', '__self_class__', '__doc__']
from which it's clear that the super object overrides __getattribute__
but not __getattr__.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
so that you keep whatever indentation the line had before.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nding mode for
floats.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 23/07/20 12:23 pm, dn wrote:
You be sure to have a nice day, now!
How do you feel about you be sure to have a nice day, now?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ue
>>> os.lstat('test2/spam/..').st_ino == os.lstat('test2').st_ino
True
What happens if you go one level deeper? I.e. is
os.lstat('test1/spam/eggs/../..').st_ino == os.lstat('test1').st_ino
and
os.lstat('test2/spam/eggs/../..').st_ino == os.lstat('test2').st_ino
?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
normal brackets, but
there are a few interesting ones, such as LEFT/RIGHT WHITE/BLACK
LENTICULAR BRACKET and LEFT/RIGHT TORTOISE SHELL BRACKET.
〖 〗【 】〔 〕
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
empty __init__.py in
Python 3.8 and there was no problem:
% ls -l empty
total 0
-rw-r--r-- 1 greg staff 0 20 Sep 12:00 __init__.py
% python3
Python 3.8.2 (default, Mar 23 2020, 11:36:18)
[Clang 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits"
chine it seems to be about 17 times slower than using
a trailing comma:
>>> timeit.repeat("tuple(['first'])")
[0.1774688908953, 0.1768788059062, 0.1768771102082,
0.176763284033, 0.17684489200001963]
>>> timeit.repeat("('first',)")
[0.0117392889055, 0.01156933400708, 0.01158800017473,
0.01156976132486, 0.01157938358281]
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
so
rarely needed. Although it probably wouldn't be as fast as an
LC could potentially be, due to the need to call a user-supplied
function for every item.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
had this way
of using "pass" in mind. More likely they're just trying to be helpful
and save you from having to manually unindent in a few rare situations.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ve you tried using a different name, such as "my_types.py"?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
actually do any harm if someone instantiated your
base class? If not, then it's probably not worth going out
of your way to prevent it.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ed=True does *not*
make your result biased -- quite the contrary!)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
en changes occur.
On the other hand, if the toolkit wraps the platform's native widgets,
it gets all the correct appearance and behaviour, and automatically
tracks changes.
For these reasons I regard "uses native widgets" as a mark of quality
for a toolkit.
--
Greg
--
https://mail.py
of the
standard offerings from Microsoft such as WinForms rather than
rolling your own.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ery different things...
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
gives you another view of the underlying data.
This is a trap you need to watch out for, since it's
different from the way sequences normally behave in
Python.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ntics with respect to particular
types -- that's left to the type checkers.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
nterpreter?
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
the limit is
about 1000. So if you have a large graph with a path more than
1000 steps long, you can hit the recursion limit.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
macros effectively let you do something similar.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
g
but functions.
This is mainly of theoretical interest; it's not usually a
practical way to go about things. But it's a good exercise
in thinking about functions as objects to be manipulated.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
On 3/01/21 12:30 am, Alan Bawden wrote:
So as long as the OP's commands are no longer than 512 bytes, and as
long as they are careful to send commands in a single call to write(),
Also note that's one write() system call, which may or may not
correspond to one Python write() call
x27;b', 'c'], 3, [], words)
print(words)
For this particular problem it's less efficient than the
technique used by itertools.product, because it generates
sub-combinations multiple times. However, it's a useful
technique to keep in mind whenever you have a "variable
number o
On 9/01/21 11:17 am, Martin Schöön wrote:
"regardless of what you have been told, recreational use of
mathematics is harmless"
I hope that is true for recreational programming as well :-)
Mostly harmless, but it can be addictive!
--
Greg
--
https://mail.python.org/mailman/listi
On 9/01/21 12:10 pm, pascal z wrote:
any way to attach a file because I loose indentation?
Indentation usually makes it through here if you indent with
spaces rather than tabs.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
"credits" or "license" for more information.
>>> s = 'Hello World'
>>> s
'Hello World'
>>> b = s.encode('ascii')
>>> b
b'Hello World'
>>> s2 = b.decode('ascii')
>>> s2
'Hello World'
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
look right to
you, it may be the fault of whatever you're using to read
the group.
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
ard python distribution, gives low-level access to C library
functions).
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list
deDecodeError: 'utf8' codec can't decode bytes in position 13-18:
unsupported Unicode code range
does anyone have any idea on what could be going wrong? The string
that I store in the database table is:
'Keinen Text für Übereinstimmungsfehler gefunden'
I thought that all st
Thank you for all your suggestions. I ended up casting the string to
unicode prior to inserting into the database.
Greg Miller
--
http://mail.python.org/mailman/listinfo/python-list
Thanks again, I'll look into this method.
Greg Miller
--
http://mail.python.org/mailman/listinfo/python-list
ass ttys, on most of
which it is physically impossible to write characters
without the cursor moving. The best you can do is move
it back to where you want it afterwards.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac
this before, and having used the odbc module for about a
year now, I'm at a quandary; what does this mean and what do I do to fix it?
Thanks!
--greg
--
Greg Lindstrom 501 975.4859
Computer Programmer [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are
(re does not like
the control characters, I guess). Is it possible for me to pull out the
formfeeds in a straightforward manner?
Thanks!
--greg
--
Greg Lindstrom 501 975.4859
Computer Programmer [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are the
n, if
possible. What can you recommend for the task?
Thanks...and see you all at PyCon!
--greg
--
Greg Lindstrom 501 975.4859
Computer Programmer [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are the music makers, and we are the dreamers of dreams." W.W.
ore I
either write one or use one that I have written in Perl?
Thanks!
--greg--
Greg Lindstrom 501 975.4859
Computer Programmer [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
"We are the music makers, and we are the dreamers of dreams." W.W.
--
http://
A bit off topic, but what does the expression "Don't try to teach your
grandfather how to suck eggs." mean? I've never heard it before and am
curious to the story behind it.
Thanks,
--greg
--
http://mail.python.org/mailman/listinfo/python-list
I have a .DLL that I am extracting the file version from using wmi.py.
The specific code is:
c = wmi.WMI()
for f in
c.CIM_DataFile(Name="c:\\glossersdmsservices\\bin\\glosscmanager.dll"):
sdmsver = f.Version
this works fine when running the application as a python file, when I
that since it cleared the problem here, it will also clear the problem
on that machine, ( the error message was slightly different ), so once
again thanks again.
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Hello again, I put the executable on the "virgin" PC today. I am using
the wmi(b) that you gave me. The error that I am receiving now is:
File "autoStart.pyc", line 241, in test
File "wmib.pyc", line 157, in ?
File "win32com\client\__init__.pyc", line 73, in GetObject
File "win32com\client\__ini
The two machines are both running Windows XP, the desktop is running XP
Pro, the "virgin" PC is running XP embedded. I would say the biggest
difference is that the embedded machine has only the py2exe executable
running/installed, while the desktop has the full python24
installation. I get no bui
I put you code snippet into my code, running it from the desktop PC
gave me the following output ( I added a print statement ):
. . . winmgmts:
T i.Caption is \\rocps00101\ROCPR001
T i.Caption is \\ROCPS00101\ROCPR024
T i.Caption is \\ROCPS00101\R
line 157 is in fact where the traceback says the failure is:
File "autoStart.py", line 241, in test
File "wmib.pyc", line 157, in ?
File "win32com\client\__init__.pyc", line 73, in GetObject
File "win32com\client\__init__.pyc", line 88, in Moniker
com_error: (-2147221020, 'Invalid syntax', None, N
Unfortunately I have a "fire" to put out with a patch to the existing
machine code, I'll get back to looking into the problem a little later.
Thanks very much for you assistance with this! I really didn't look
into the GetFileVersionInfo, can I assume that is a cytypes function?
--
http://mail.
I didn't see the earlier post, thanks for the resend. The firefighting
is just about over, I have to find the machine owner to get permission
to try the code. Then back to the dll version battle. If I can keep
away from dealing with the ctypes code I will. I'll see how this works
for me. Thank
I tried the code snippet using win32api.GetFileVersionInfo(), what I
get now is the following when running on the executable machine:
. . . FileFlagsMask => 63
FileType => 2
FileVersionMS => 65536
FileVersionLS => 1
Signature => -17890115
FileSubtype => 0
FileFlags => 0
ProductVersionLS => 1
FileD
time. It's been a good learning experience for me.
Now on with the project....Greg
--
http://mail.python.org/mailman/listinfo/python-list
That code works great, and is a tad bit cleaner than what I came up
with, thanks again.
--
http://mail.python.org/mailman/listinfo/python-list
stand/use.
Regular expressions are not either, though I use them all the time (I
learned them when I was a system admin on a Sun network and tend to
fall back on them when I need a "quick fix"). I hear that Perl 6 is
going to have a rewrite of regular expressions; it will be interesting
t
t is to be done,
instead of writing code to do it.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
--
http://mail.python.org/mailman/listinfo/python-list
do not see a way.
Any suggestions? As it stands now, I'm printing sending 200 files,
waiting until the queue is clear, then another 200, and so forth.
Eventually we will be paperless (if for no other reason this seems
insane to me), but what can I do in the meantime?
Thanks for you
r whatever it's called on windows) to detect when
a new file is created in a directory and, more importantly, when it is
"complete" (if that makes sense)?
Thanks for your help.
--greg
--
Greg Lindstrom 501 975.4859 (office)
Senior Programmer
ct. When you
show them that Python "works" and that they will be able to understand
the code, I'm guessing they will let you do more. Before you know it,
you're coding everything in Python.
Best of luck,
--greg
--
http://mail.python.org/mailman/listinfo/python-list
ficulty with is the resetting the modification time. According to the O'Reilly book I have, using utime in this way - os.utime(testfile, (1124137226, 1124137227)) (those are just sample numbers) - would do so, but I'm generating an OSError. Any Ideas?
Greg Peretti
web developer
www.
I have a Python snippet:
f = open("blah.txt", "r")
while True:
c = f.read(1)
if c == '': break # EOF
# ... work on c
Is some way to make this code more compact and simple? It's a bit
spaghetti.
This is what I would ideally like:
f = open("blah.txt", "r")
while c = f.re
Okay, the 1st option seems more complicated and the 2nd option, while
simpler to my eye makes me worry about file descriptors, resource
management and memory running out.
My files are large, hence 1 character at a time, not f.read().
This is code from another employee and I'm just in the stages o
The 2nd option has real potential for me. Although the total amount of
code is greater, it factors out some complexity away from the actual
job, so that code is not obscured by unnecessary compexity. IMHO that's
great practice.
I like it! Thank you! The assurance that the code was clear was good
t
601 - 700 of 1198 matches
Mail list logo